createOrThrow
The createOrThrow() function builds a TheDate from a TheDate, a Date, or a timestamp. It throws CreateTheDateError when the input is invalid.
Interactive example
Syntax
typescript
function createOrThrow<
GenericInput extends TheDate | Date | number
>(
input: GenericInput
): TheDateParameters
input: A date (TheDate), a JavaScriptDate, or a timestamp.
Return value
A valid TheDate. If the timestamp is out of bounds or the value is inconsistent, a CreateTheDateError is thrown.
See also
create– Returns anEitherinstead of throwing.isSafeTimestamp– Checks a timestamp before conversion.
