make wantsDateSeparator generic and throw into DateUtils
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
e45fcf10c7
commit
1a7dc22a8d
3 changed files with 21 additions and 31 deletions
|
@ -100,3 +100,17 @@ export function formatTime(date, showTwelveHour=false) {
|
|||
}
|
||||
return pad(date.getHours()) + ':' + pad(date.getMinutes());
|
||||
}
|
||||
|
||||
const MILLIS_IN_DAY = 86400000;
|
||||
export function wantsDateSeparator(prevEventDate, nextEventDate) {
|
||||
if (!nextEventDate || !prevEventDate) {
|
||||
return false;
|
||||
}
|
||||
// Return early for events that are > 24h apart
|
||||
if (Math.abs(prevEventDate.getTime() - nextEventDate.getTime()) > MILLIS_IN_DAY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Compare weekdays
|
||||
return prevEventDate.getDay() !== nextEventDate.getDay();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue