mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-13 05:48:36 +03:00
nicer dates in timeline header
This commit is contained in:
@@ -211,3 +211,19 @@ export function findDescriptionInFilterTree (key, node) {
|
||||
if (descs.length !== 1) return false
|
||||
return descs[0]
|
||||
}
|
||||
|
||||
export function makeNiceDate (datetime) {
|
||||
if (datetime === null) return null
|
||||
// see https://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date
|
||||
const dateTimeFormat = new Intl.DateTimeFormat(
|
||||
'en',
|
||||
{ year: 'numeric', month: 'long', day: '2-digit' }
|
||||
)
|
||||
const [
|
||||
{ value: month },,
|
||||
{ value: day },,
|
||||
{ value: year }
|
||||
] = dateTimeFormat.formatToParts(datetime)
|
||||
|
||||
return `${day} ${month}, ${year}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user