diff options
author | Eric Bailey <git@esb.lol> | 2024-08-29 19:22:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-29 19:22:53 -0500 |
commit | 8651f31ebb7cf9c6a0949503f2c2c5755328ce46 (patch) | |
tree | 04f9c08a3770cee554a6cd421a53dc04957457fb /src/components/dms | |
parent | d5a76183746bc67f88b858add49c2dba52b99bb5 (diff) | |
download | voidsky-8651f31ebb7cf9c6a0949503f2c2c5755328ce46.tar.zst |
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>
Diffstat (limited to 'src/components/dms')
-rw-r--r-- | src/components/dms/MessageItem.tsx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/components/dms/MessageItem.tsx b/src/components/dms/MessageItem.tsx index 573c24f77..c5c472cf0 100644 --- a/src/components/dms/MessageItem.tsx +++ b/src/components/dms/MessageItem.tsx @@ -11,6 +11,7 @@ import { ChatBskyConvoDefs, RichText as RichTextAPI, } from '@atproto/api' +import {I18n} from '@lingui/core' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -153,14 +154,14 @@ let MessageItemMetadata = ({ ) const relativeTimestamp = useCallback( - (timestamp: string) => { + (i18n: I18n, timestamp: string) => { const date = new Date(timestamp) const now = new Date() - const time = new Intl.DateTimeFormat(undefined, { + const time = i18n.date(date, { hour: 'numeric', minute: 'numeric', - }).format(date) + }) const diff = now.getTime() - date.getTime() @@ -182,13 +183,13 @@ let MessageItemMetadata = ({ return _(msg`Yesterday, ${time}`) } - return new Intl.DateTimeFormat(undefined, { + return i18n.date(date, { hour: 'numeric', minute: 'numeric', day: 'numeric', month: 'numeric', year: 'numeric', - }).format(date) + }) }, [_], ) |