-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle session idempotency & fix days_until_due issue
- Loading branch information
1 parent
f677da3
commit a5cea92
Showing
8 changed files
with
36 additions
and
11 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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export const timePeriods = ["day", "week", "month", "year"] as const; | ||
|
||
export const SECONDS_IN_A_DAY = 86_400n; // 60 * 60 * 24 seconds in a day | ||
|
||
// TODO(KK): get this from the widget repo but might need to handle dual packages first | ||
export const mapTimePeriodToSeconds = (timePeriod: TimePeriod): bigint => { | ||
switch (timePeriod) { | ||
case "day": | ||
return SECONDS_IN_A_DAY; | ||
case "week": | ||
return 604800n; // 60 * 60 * 24 * 7 seconds in a week | ||
case "month": | ||
return 2628000n; // 60 * 60 * 24 * 30 seconds in a month (approximation) | ||
case "year": | ||
return 31536000n; // 60 * 60 * 24 * 365 seconds in a year (approximation) | ||
default: | ||
throw new Error(`Invalid time period: ${timePeriod}`); | ||
} | ||
}; | ||
|
||
export type TimePeriod = (typeof timePeriods)[number]; |
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
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
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