{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:open-utility-stack:common:time:1",
  "title": "common/time@1",
  "description": "Instants are UTC; business dates are civil dates in a named zone.",
  "$defs": {
    "Instant": {
      "description": "RFC 3339 in UTC, ending in `Z`.",
      "type": "string",
      "format": "date-time",
      "pattern": "Z$"
    },
    "Date": {
      "description": "A civil date, YYYY-MM-DD.",
      "type": "string",
      "format": "date"
    },
    "Zone": {
      "description": "An IANA time-zone name. The stack's business zone is Europe/Berlin.",
      "type": "string",
      "pattern": "^[A-Za-z][A-Za-z0-9_+-]*(/[A-Za-z0-9_+-]+)*$",
      "maxLength": 64
    },
    "LocalTime": {
      "description": "A local wall-clock time, HH:MM, 00:00 to 23:59.",
      "type": "string",
      "pattern": "^([01][0-9]|2[0-3]):[0-5][0-9]$"
    },
    "ZonedDate": {
      "description": "A business date and the zone it is a day in.",
      "type": "object",
      "additionalProperties": false,
      "required": ["date", "zone"],
      "properties": {
        "date": { "$ref": "#/$defs/Date" },
        "zone": { "$ref": "#/$defs/Zone" }
      }
    },
    "DatePeriod": {
      "description": "Business dates, both ends inclusive: a billing period, a service period.",
      "type": "object",
      "additionalProperties": false,
      "required": ["from", "to", "zone"],
      "properties": {
        "from": { "$ref": "#/$defs/Date" },
        "to": { "$ref": "#/$defs/Date" },
        "zone": { "$ref": "#/$defs/Zone" }
      }
    },
    "Window": {
      "description": "Instants, half-open: `from` inclusive, `until` exclusive.",
      "type": "object",
      "additionalProperties": false,
      "required": ["from", "until"],
      "properties": {
        "from": { "$ref": "#/$defs/Instant" },
        "until": { "$ref": "#/$defs/Instant" }
      }
    }
  }
}
