[api] Add datetime util for start-end ranges
This commit is contained in:
parent
664def40fc
commit
e4889ddac2
|
@ -25,6 +25,17 @@ export function asHour(date?: Date) {
|
|||
return date ? formatDateTime(date, false, true) : '';
|
||||
}
|
||||
|
||||
export function formatStartEnd(start: Date, end?: Date) {
|
||||
const today = asDate(new Date());
|
||||
const startDate = asDate(start);
|
||||
const endDate = end ? asDate(end) : '';
|
||||
return (
|
||||
(today !== startDate ? `${startDate}, ` : '') +
|
||||
asHour(start) +
|
||||
(end ? ' - ' + (endDate !== startDate ? `${endDate}, ` : '') + asHour(end) : '')
|
||||
);
|
||||
}
|
||||
|
||||
export function startOfWeek(date: Date, startMonday = true) {
|
||||
const start = new Date(date);
|
||||
const day = date.getDay() || 7;
|
||||
|
|
Loading…
Reference in New Issue