isValidUtc
Signature
Section titled “Signature”isValidUtc(value: string): booleanimport { isValidUtc } from "@northguild/gmt/utc/validate";Return true when the provided string is a valid ISO 8601 UTC datetime.
- Uses regex to check format before parsing.
- Rejects leap seconds (e.g., “2024-12-31T23:59:60Z”).
- Uses Temporal.Instant.from for validation.
- Requires a time component — date-only strings (“2024-01-01Z”) are rejected.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string |
input UTC datetime string (ISO 8601) |
Returns
Section titled “Returns”boolean indicating whether the input is a valid UTC datetime
Examples
Section titled “Examples”isValidUtc("2024-03-17T14:30:45Z") // trueisValidUtc("2024-01-01Z") // false — date-only not supportedisValidUtc("2024-12-31T23:59:60Z") // falseisValidUtc("invalid") // false