-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kerosene: Update date-fns to v4 for @date-fns/tz support via options (#…
…152)
- Loading branch information
Showing
8 changed files
with
47 additions
and
19 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
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,13 +1,20 @@ | ||
import { startOfDay } from "date-fns"; | ||
import { startOfDay, type ContextOptions } from "date-fns"; | ||
|
||
export type IsAfterDayOptions = ContextOptions<Date>; | ||
|
||
/** | ||
* Returns whether the day of `date` is after the day of `dateToCompare` | ||
* @param date | ||
* @param dateToCompare | ||
* @param options | ||
*/ | ||
export default function isAfterDay( | ||
date: Date | number, | ||
dateToCompare: Date | number, | ||
options?: IsAfterDayOptions, | ||
): boolean { | ||
return startOfDay(date).getTime() > startOfDay(dateToCompare).getTime(); | ||
return ( | ||
startOfDay(date, options).getTime() > | ||
startOfDay(dateToCompare, options).getTime() | ||
); | ||
} |
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,13 +1,20 @@ | ||
import { startOfDay } from "date-fns"; | ||
import { startOfDay, type ContextOptions } from "date-fns"; | ||
|
||
export type IsBeforeDayOptions = ContextOptions<Date>; | ||
|
||
/** | ||
* Returns whether the day of `date` is before the day of `dateToCompare` | ||
* @param date | ||
* @param dateToCompare | ||
* @param options | ||
*/ | ||
export default function isBeforeDay( | ||
date: Date | number, | ||
dateToCompare: Date | number, | ||
options?: IsBeforeDayOptions, | ||
): boolean { | ||
return startOfDay(date).getTime() < startOfDay(dateToCompare).getTime(); | ||
return ( | ||
startOfDay(date, options).getTime() < | ||
startOfDay(dateToCompare, options).getTime() | ||
); | ||
} |
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,14 +1,21 @@ | ||
import { isSameDay } from "date-fns"; | ||
import { isSameDay, type ContextOptions } from "date-fns"; | ||
import isAfterDay from "./isAfterDay"; | ||
|
||
export type IsSameOrAfterDayOptions = ContextOptions<Date>; | ||
|
||
/** | ||
* Returns whether the day of `date` is the same or after the day of `dateToCompare` | ||
* @param date | ||
* @param dateToCompare | ||
* @param options | ||
*/ | ||
export default function isSameOrAfterDay( | ||
date: Date | number, | ||
dateToCompare: Date | number, | ||
options?: IsSameOrAfterDayOptions, | ||
): boolean { | ||
return isSameDay(date, dateToCompare) || isAfterDay(date, dateToCompare); | ||
return ( | ||
isSameDay(date, dateToCompare, options) || | ||
isAfterDay(date, dateToCompare, options) | ||
); | ||
} |
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,14 +1,21 @@ | ||
import { isSameDay } from "date-fns"; | ||
import { isSameDay, type ContextOptions } from "date-fns"; | ||
import isBeforeDay from "./isBeforeDay"; | ||
|
||
export type IsSameOrBeforeDayOptions = ContextOptions<Date>; | ||
|
||
/** | ||
* Returns whether the day of `date` is the same or before the day of `dateToCompare` | ||
* @param date | ||
* @param dateToCompare | ||
* @param options | ||
*/ | ||
export default function isSameOrBeforeDay( | ||
date: Date | number, | ||
dateToCompare: Date | number, | ||
options?: ContextOptions<Date>, | ||
): boolean { | ||
return isSameDay(date, dateToCompare) || isBeforeDay(date, dateToCompare); | ||
return ( | ||
isSameDay(date, dateToCompare, options) || | ||
isBeforeDay(date, dateToCompare, options) | ||
); | ||
} |
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