Created
July 2, 2021 14:25
-
-
Save jsjoeio/f3e5c0977714d23da4e0654645b7bd01 to your computer and use it in GitHub Desktop.
opaque type example (DateInTimezone)
This file contains hidden or 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
declare const _date: unique symbol | |
export type DateInTimezone = Date & { readonly [_date]: Date } | |
/** | |
* Checks if the date is between 12am and 4am | |
* of the day | |
* | |
* Returns true if it is, false otherwise | |
**/ | |
export function isBetween12amAnd4am(date: DateInTimezone) { | |
const hours = date.getHours() | |
return hours >= 0 && hours < 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment