Date and time types
isoDate
Section titled “isoDate”A date on a calendar in ISO 8601 format YYYY-MM-DD.
A JSON example of this model.
"2025-01-01"The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: isoDate.yamltype: stringformat: dateexamples: - 2025-01-01description: A date on a calendar in ISO 8601 format YYYY-MM-DDThe TypeSpec code for this model.
// ########################################// Date types// ########################################The TypeScript code for this model.
d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds() )isoTime
Section titled “isoTime”A time on a clock, without a timezone, in ISO 8601 format HH:mm:ss.
A JSON example of this model.
"17:00:00"The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: isoTime.yamltype: stringformat: timeexamples: - 17:00:00description: A time on a clock, without a timezone, in ISO 8601 format HH:mm:ssThe TypeSpec code for this model.
@example("100.5", #{ title: "Scale 1" })@example("-100.5", #{ title: "Negative, scale 2" })@Versioning.added(CommonGrants.Versions.v0_1)scalar decimalString extends string;The TypeScript code for this model.
/** * Accept a `Date` as input by normalizing it to a string before the string * validators run, so a caller can pass either an ISO string or a `Date`. A * string goes straight to the inner schema's strict validation; a valid `Date` * is rendered by `toStr` into the string format the inner schema expects. An * invalid `Date` is passed through unchanged so the inner validator rejects it, * rather than throwing a `RangeError` out of `toISOString()` and escapingutcDateTime
Section titled “utcDateTime”A date and time with timezone in ISO 8601 format YYYY-MM-DDThh:mm:ssZ.
A JSON example of this model.
"2024-02-28T17:00:00Z"The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: utcDateTime.yamltype: stringformat: date-timedescription: A date and time with timezone in ISO 8601 format YYYY-MM-DDThh:mm:ssZThe TypeScript code for this model.
d.getUTCMonth(),offsetDateTime
Section titled “offsetDateTime”A date and time with timezone in ISO 8601 format YYYY-MM-DDThh:mm:ss±hh:mm.
A JSON example of this model.
"2024-02-28T17:00:00+01:00"The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: offsetDateTime.yamltype: stringformat: date-timedescription: A date and time with timezone in ISO 8601 format YYYY-MM-DDThh:mm:ss±hh:mmThe TypeScript code for this model.
const acceptDate = (toStr: (d: Date) => string) => (val: unknown): unknown => val instanceof Date && !isNaN(val.getTime()) ? toStr(val) : val;calendarYear
Section titled “calendarYear”A calendar year in the format YYYY.
A JSON example of this model.
"2025"The JSON Schema for this model.
$schema: https://json-schema.org/draft/2020-12/schema$id: calendarYear.yamltype: stringexamples: - "2025"pattern: ^[0-9]{4}$description: A calendar yearThe TypeSpec code for this model.
@example(isoTime.fromISO("17:00:00"))@Versioning.added(CommonGrants.Versions.v0_1)scalar isoTime extends plainTime;
/** A date on a calendar in ISO 8601 format YYYY-MM-DD */