Created
September 19, 2021 16:15
-
-
Save majirosstefan/ffaca694785b33d714db35df9b70d9a5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import moment from 'moment'; | |
import {momentLocalesFileMappings} from './translationFileMappings'; | |
const DATE_FORMAT = 'YYYY-DD-MM'; | |
// 💖 Here we tell moment to change locale in runtime | |
export const setMomentLocale = async locale => { | |
momentLocalesFileMappings[locale](); | |
return moment().locale(locale); | |
}; | |
export function parseUnixDate(unixDate) { | |
return moment.unix(unixDate).format(DATE_FORMAT); | |
} | |
export const nowUnixDate = () => { | |
return moment().unix(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment