UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

25 lines • 1.26 kB
/** * Return true when `value` is a valid ISO PlainTime string. * * - The whole string must match `plainTime`. * - Accepts no annotation of any kind: a time zone, a calendar (`[u-ca=iso8601]`) or an * elective one (`[foo=bar]`) returns `false`. * - Rejects leap seconds (e.g., "23:59:60"). * - Rejects invalid times (e.g., "24:00:00", "23:60:00"). * - A value that is not a string, a `String` object included, returns `false`. A `true` result * narrows an `unknown` value to `string`. * * @param value any value; a string is checked as an ISO PlainTime * @returns boolean indicating validity * * @example isValidTime("12:34:56") // true * @example isValidTime("24:00:00") // false (invalid hour) * @example isValidTime("12:34:56[u-ca=hebrew]") // false (no annotation of any kind) * @example isValidTime("12:34:56[!foo=bar]") // false (no annotation of any kind) * @example isValidTime("23:60:00") // false (invalid minute) * @example isValidTime("23:59:60") // false (leap second) * @example isValidTime(null) // false */ export declare function isValidTime(value: string): boolean; export declare function isValidTime(value: {} | null | undefined | void): boolean; export declare function isValidTime(value: unknown): value is string;