Localize dates, counts (#5027)
* refactor: consistent localized formatting * refactor: localized date time * refactor: localize relative time with strings * chore: fix typo from copy-paste * Clean up useTimeAgo * Remove old ago * Const * Reuse * Prettier --------- Co-authored-by: Mary <git@mary.my.id>
This commit is contained in:
parent
d5a7618374
commit
8651f31ebb
21 changed files with 375 additions and 186 deletions
|
@ -1,13 +1,12 @@
|
|||
export function niceDate(date: number | string | Date) {
|
||||
import {I18n} from '@lingui/core'
|
||||
|
||||
export function niceDate(i18n: I18n, date: number | string | Date) {
|
||||
const d = new Date(date)
|
||||
return `${d.toLocaleDateString('en-us', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
})} at ${d.toLocaleTimeString(undefined, {
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
})}`
|
||||
|
||||
return i18n.date(d, {
|
||||
dateStyle: 'long',
|
||||
timeStyle: 'short',
|
||||
})
|
||||
}
|
||||
|
||||
export function getAge(birthDate: Date): number {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue