Bluesky app fork with some witchin' additions 馃挮 witchsky.app
bluesky fork client
at main 27 lines 714 B view raw
1/** 2 * Hooks for date-fns localized formatters. 3 * 4 * Our app supports some languages that are not included in date-fns by 5 * default, in which case it will fall back to English. 6 * 7 * {@link https://github.com/date-fns/date-fns/blob/main/docs/i18n.md} 8 */ 9 10import {useCallback} from 'react' 11import {formatDistance} from 'date-fns' 12 13import {useDateLocale} from '#/locale/i18nProvider' 14 15/** 16 * Returns a localized `formatDistance` function. 17 * {@link formatDistance} 18 */ 19export function useFormatDistance() { 20 const locale = useDateLocale() 21 return useCallback<typeof formatDistance>( 22 (date, baseDate, options) => { 23 return formatDistance(date, baseDate, {...options, locale}) 24 }, 25 [locale], 26 ) 27}