Skip to content

Instantly share code, notes, and snippets.

@majirosstefan
Created September 19, 2021 16:15
Show Gist options
  • Save majirosstefan/ffaca694785b33d714db35df9b70d9a5 to your computer and use it in GitHub Desktop.
Save majirosstefan/ffaca694785b33d714db35df9b70d9a5 to your computer and use it in GitHub Desktop.
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