-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from concord-consortium/188382072-change-defau…
…lt-date-to-today fix: Change default end date to today [PT-188382072]
- Loading branch information
Showing
2 changed files
with
11 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
const padNumber = (num: number): string => num.toString().padStart(2, "0"); | ||
const dateToString = (d: Date) => `${d.getFullYear()}-${padNumber(d.getMonth() + 1)}-${padNumber(d.getDate())}` | ||
|
||
const yesterdayDate = new Date(); | ||
yesterdayDate.setDate(yesterdayDate.getDate() - 1); | ||
const oneYearAgoFromYesterdayDate = new Date(yesterdayDate); | ||
oneYearAgoFromYesterdayDate.setFullYear(oneYearAgoFromYesterdayDate.getFullYear() - 1); | ||
// default to end today | ||
const defaultEndDate = new Date(); | ||
|
||
export const yesterday = dateToString(yesterdayDate); | ||
export const oneYearAgoFromYesterday = dateToString(oneYearAgoFromYesterdayDate); | ||
// default to start one year ago | ||
const defaultStartDate = new Date(defaultEndDate); | ||
defaultStartDate.setFullYear(defaultStartDate.getFullYear() - 1); | ||
|
||
export const defaultStart = dateToString(defaultEndDate); | ||
export const defaultEnd = dateToString(defaultStartDate); | ||
|