Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date-fns localizer #1542

Merged
merged 6 commits into from
Dec 9, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
format updates for fns 2.0
  • Loading branch information
harel committed Dec 4, 2019
commit 444a001b5bf6b6835da7fd88f535f417e8d4f4b3
21 changes: 10 additions & 11 deletions src/localizers/date-fns.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
import * as dates from '../utils/dates'
import { DateLocalizer } from '../localizer'

let dateRangeFormat = ({ start, end }, culture, local) => {
return (
local.format(start, 'P', culture) + ' — ' + local.format(end, 'P', culture)
)
}
let dateRangeFormat = ({ start, end }, culture, local) =>
`${local.format(start, 'P', culture)} – ${local.format(end, 'P', culture)}`

let timeRangeFormat = ({ start, end }, culture, local) =>
local.format(start, 'p', culture) + ' — ' + local.format(end, 'p', culture)
`${local.format(start, 'p', culture)} – ${local.format(end, 'p', culture)}`

let timeRangeStartFormat = ({ start }, culture, local) =>
local.format(start, 'h:mma', culture) + ' — '
`${local.format(start, 'h:mma', culture)} – `

let timeRangeEndFormat = ({ end }, culture, local) =>
' — ' + local.format(end, 'h:mma', culture)
` – ${local.format(end, 'h:mma', culture)}`

let weekRangeFormat = ({ start, end }, culture, local) =>
local.format(start, 'MMMM dd', culture) +
' - ' +
local.format(end, dates.eq(start, end, 'month') ? 'dd' : 'MMMM dd', culture)
`${local.format(start, 'MMMM dd', culture)} – ${local.format(
end,
dates.eq(start, end, 'month') ? 'dd' : 'MMMM dd',
culture
)}`

export let formats = {
dateFormat: 'dd',
Expand Down