Files
notesnook/packages/core/utils/date.js

25 lines
660 B
JavaScript
Raw Normal View History

import dayjs from "dayjs";
2019-12-12 11:49:06 +05:00
export function getWeekGroupFromTimestamp(timestamp) {
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
}
export function formatDate(date) {
return new Date(date).toLocaleDateString("en", {
day: "numeric",
month: "long",
year: "numeric",
hour: "2-digit",
hour12: true,
minute: "2-digit",
second: "2-digit",
});
}