From a0f94af7e8033552c524787c7ef5b76fa75ae1e0 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 10 Dec 2024 11:16:32 -0500 Subject: [PATCH] enh: Accept UTC offsets in datetimes --- src/common-principles.md | 13 ++++++------- src/schema/objects/formats.yaml | 22 ++++++++++++++++++---- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/common-principles.md b/src/common-principles.md index 4e5509ac7b..7486747f9b 100644 --- a/src/common-principles.md +++ b/src/common-principles.md @@ -1009,16 +1009,15 @@ For additional rules, see below: Describing dates and timestamps: - Date time information MUST be expressed in the following format - `YYYY-MM-DDThh:mm:ss[.000000][Z]` (year, month, day, hour (24h), minute, - second, optional fractional seconds, and optional UTC time indicator). + `YYYY-MM-DDThh:mm:ss[.000000][Z|+hh:mm|-hh:mm]` (year, month, day, hour (24h), + minute, second, optional fractional seconds, and optional time offset). This is almost equivalent to the [RFC3339](https://tools.ietf.org/html/rfc3339) - "date-time" format, with the exception that UTC indicator `Z` is optional and - non-zero UTC offsets are not indicated. - If `Z` is not indicated, time zone is always assumed to be the local time of the - dataset viewer. + "date-time" format, with the exception that UTC offsets are OPTIONAL. + If no time offset is indicated, + time zone is always assumed to be the local time of the dataset viewer. No specific precision is required for fractional seconds, but the precision SHOULD be consistent across the dataset. - For example `2009-06-15T13:45:30`. + For example `2009-06-15T13:45:30+01:00`. - Time stamp information MUST be expressed in the following format: `hh:mm:ss[.000000]` diff --git a/src/schema/objects/formats.yaml b/src/schema/objects/formats.yaml index 7de4345b2d..1f2552bee7 100644 --- a/src/schema/objects/formats.yaml +++ b/src/schema/objects/formats.yaml @@ -69,10 +69,24 @@ date: datetime: display_name: Datetime description: | - A datetime in the form `"YYYY-MM-DDThh:mm:ss[.000000][Z]"`, - where [.000000] is an optional subsecond resolution between 1 and 6 decimal points, - and [Z] is an optional, valid timezone code. - pattern: '[0-9]{4}-[0-9]{2}-[0-9]{2}T(?:2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9](\.[0-9]{1,6})?([A-Z]{2,4})?' + An [RFC 3339](https://doi.org/10.17487/RFC3339) timestamp, with OPTIONAL time offset. + Datetimes take the form `"YYYY-MM-DDThh:mm:ss[.000000][Z|+hh:mm|-hh:mm]"`, + where `[.000000]` is an OPTIONAL subsecond resolution between 1 and 6 decimal points, + and `[Z|+hh:mm|-hh:mm]` is a time offset. + The character `Z` indicates Coordinated Universal Time (UTC), + or else an integral number of minutes may be specified. + + For simplicity, this format validates RFC3339-invalid dates such as 2024-02-31, + but implementations SHOULD error on non-existent dates and times. + pattern: "\ + [0-9]{4}\ + -(?:0[1-9]|1[0-2])\ + -(?:0[1-9]|[12][0-9]|3[01])\ + T(?:2[0-3]|[01][0-9])\ + :[0-5][0-9]\ + :(?:[0-5][0-9]|60)\ + (?:\\.[0-9]{1,6})?\ + (?:Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?" file_relative: display_name: Path relative to the parent file description: |