// returns a new date shifted a certain number of days (can be negative)
export function shiftDate(date, numDays) {
const newDate = new Date(date);
newDate.setDate(newDate.getDate() + numDays);
return newDate;
}
export function getBeginningTimeForDate(date) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
}
// obj can be a parseable string, a millisecond timestamp, or a Date object
export function convertToDate(obj) {
return (obj instanceof Date) ? obj : (new Date(obj));
}
export function dateNDaysAgo(numDaysAgo) {
return shiftDate(new Date(), -numDaysAgo);
}
export function getRange(count) {
return Array.from({ length: count }, (_, i) => i);
}
|