Skip to content

Commit

Permalink
enh: Accept UTC offsets in datetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Dec 10, 2024
1 parent 46d2399 commit a0f94af
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
13 changes: 6 additions & 7 deletions src/common-principles.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]`
Expand Down
22 changes: 18 additions & 4 deletions src/schema/objects/formats.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down

0 comments on commit a0f94af

Please sign in to comment.