UNPKG

react-chakra-table

Version:

a simple, sortable, filterable, react table grid - styled with chakra-ui.

21 lines (20 loc) 568 B
import dayjs from "dayjs"; import LocalizedFormat from "dayjs/plugin/localizedFormat"; /** * Returns date as readable string. If date is empty, returns current date. * @param date * @param withTime * @param language * @returns */ export const getDate = (date, withTime, language) => { const lang = language ? language : "en"; dayjs.extend(LocalizedFormat); dayjs.locale(lang); if (withTime) return dayjs(date).format("L - LT"); return dayjs(date).format("L"); }; export const isDate = (date) => { return dayjs(date).isValid(); };