Skip to content

Commit

Permalink
Merge pull request #64 from bitovi/new-ahead
Browse files Browse the repository at this point in the history
fixing date parsing again
  • Loading branch information
justinbmeyer authored Apr 24, 2024
2 parents da799e9 + 1c0d2c2 commit af24c85
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
11 changes: 10 additions & 1 deletion public/date-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function howMuchHasDueDateMovedForwardChangedSince(epic, checkpointDate)
// Formats this takes on:
// 2023-02-17T16:58:00.000Z
// 2024-04-19T16:43:17.181-0400
// 2024-05-27
// new Date("2024-05-27") -> date in GMT 0, not in the local timezone. This can mean reporting the wrong date.
export function parseDateISOString(s) {
if (!s) return s;

Expand All @@ -53,11 +53,20 @@ export function parseDateISOString(s) {
// fix timezone to UTC
return new Date(s.getTime() + s.getTimezoneOffset() * 60 * 1000);
}
if(s.split(/\D/).length === 3) {
throw new Error("Unable to parse "+s);
}

return new Date(s);

}

export function parseDateIntoLocalTimezone(s){
let ds = s.split(/\D/).map(s => parseInt(s));
ds[1] = ds[1] - 1; // adjust month
return new Date(...ds);
}

export const DAY_IN_MS = 1000 * 60 * 60 * 24;


Expand Down
Loading

0 comments on commit af24c85

Please sign in to comment.