-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Pass locale to date-fns * Implement useDateFns
- Loading branch information
Showing
3 changed files
with
22 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { format as dformat, formatDistance as dformatDistance } from 'date-fns' | ||
import { useTranslation } from 'react-i18next' | ||
import { datesLocale } from './locales' | ||
|
||
export const useDateFns = () => { | ||
const { i18n } = useTranslation() | ||
return { | ||
format: (date: Date | number, format: string) => dformat(date, format, { locale: datesLocale(i18n.language) }), | ||
formatDistance: (date: Date | number, baseDate: Date | number) => | ||
dformatDistance(date, baseDate, { | ||
addSuffix: true, | ||
locale: datesLocale(i18n.language), | ||
}), | ||
} | ||
} |
198d5ca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Published on https://vocdoni-explorer-stg.netlify.app as production
π Deployed on https://6661a902f101ea008ab542f3--vocdoni-explorer-stg.netlify.app
198d5ca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Published on https://vocdoni-explorer-dev.netlify.app as production
π Deployed on https://6661a907d2616b1c18dbbc54--vocdoni-explorer-dev.netlify.app