saleor-dashboard/src/hooks/useDateLocalize.ts

16 lines
361 B
TypeScript
Raw Normal View History

2019-08-09 10:26:22 +00:00
import moment from "moment-timezone";
2019-06-19 14:40:52 +00:00
import { useContext } from "react";
import { LocaleContext } from "@saleor/components/Locale";
function useDateLocalize(): (date: string) => string {
2019-10-16 15:18:29 +00:00
const { locale } = useContext(LocaleContext);
2019-06-19 14:40:52 +00:00
return (date: string) =>
moment(date)
.locale(locale)
.format("ll");
}
export default useDateLocalize;