2021-07-16 18:46:16 +05:00
|
|
|
import dayjs from "dayjs";
|
2019-12-12 11:49:06 +05:00
|
|
|
|
|
|
|
|
export function getWeekGroupFromTimestamp(timestamp) {
|
2021-07-16 18:46:16 +05:00
|
|
|
const date = dayjs(timestamp);
|
|
|
|
|
const start = date.startOf("week");
|
|
|
|
|
const end = date.endOf("week");
|
|
|
|
|
const startMonth = start.month() === end.month() ? "" : " MMM";
|
|
|
|
|
const startYear = start.year() === end.year() ? "" : ", YYYY";
|
|
|
|
|
return `${start.format(`DD${startMonth}${startYear}`)} - ${end.format(
|
|
|
|
|
"DD MMM, YYYY"
|
|
|
|
|
)}`;
|
2019-12-12 11:49:06 +05:00
|
|
|
}
|
2020-08-31 13:12:09 +05:00
|
|
|
|
|
|
|
|
export function formatDate(date) {
|
2021-12-21 14:32:14 +05:00
|
|
|
return new Date(date).toLocaleString(undefined, {
|
|
|
|
|
dateStyle: "medium",
|
|
|
|
|
timeStyle: "short",
|
2020-08-31 13:12:09 +05:00
|
|
|
});
|
|
|
|
|
}
|