|
|
@ -52,8 +52,22 @@ export class RelativeDateRange { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export function customDateRange(from: Date, to: Date): DateRange { |
|
|
|
return {name: "Specific Dates", calculate: () => [from, to]} |
|
|
|
export class CustomDateRange { |
|
|
|
private from: Date; |
|
|
|
private to: Date; |
|
|
|
|
|
|
|
constructor(from: Date, to: Date) { |
|
|
|
this.from = from; |
|
|
|
this.to = to; |
|
|
|
} |
|
|
|
|
|
|
|
get name() { |
|
|
|
return "Specific Dates" |
|
|
|
} |
|
|
|
|
|
|
|
calculate(_: Date): [Date, Date] { |
|
|
|
return [this.from, this.to]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const thisWeek = dateRangeCallback("This week", date => [startOfWeek(date), endOfWeek(date)]); |
|
|
@ -96,7 +110,7 @@ export function rangeFromDates(from: Date, to: Date, options: DateRange[]): Date |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return customDateRange(from, to); |
|
|
|
return new CustomDateRange(from, to); |
|
|
|
} |
|
|
|
|
|
|
|
export const pastOffsets: DateRange[] = allOffsets.filter(r => !r.name.startsWith("Next")); |