Add a function to format just a date.

master
Tom Hacohen 6 years ago
parent c2d4027e13
commit e90a92ed57

@ -50,15 +50,24 @@ export function insertSorted<T>(array: T[] = [], newItem: T, key: string) {
return array;
}
const allDayFormat = 'dddd, LL';
const fullFormat = 'LLLL';
export function formatDate(date: ICAL.Time) {
const mDate = moment(date.toJSDate());
if (date.isDate) {
return mDate.format(allDayFormat);
} else {
return mDate.format(fullFormat);
}
}
export function formatDateRange(start: ICAL.Time, end: ICAL.Time) {
const mStart = moment(start.toJSDate());
const mEnd = moment(end.toJSDate());
let strStart;
let strEnd;
const allDayFormat = 'dddd, LL';
const fullFormat = 'LLLL';
// All day
if (start.isDate) {
if (mEnd.diff(mStart, 'days', true) === 1) {

Loading…
Cancel
Save