diff --git a/src/common-principles.md b/src/common-principles.md index dc84313594..e21ae3c6bc 100644 --- a/src/common-principles.md +++ b/src/common-principles.md @@ -1017,16 +1017,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 7e0530a1d6..dcd6102a00 100644 --- a/src/schema/objects/formats.yaml +++ b/src/schema/objects/formats.yaml @@ -77,10 +77,15 @@ 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 literal character `Z` that indicates - Coordinated Universal Time (UTC). + 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])\ @@ -89,7 +94,7 @@ datetime: :[0-5][0-9]\ :(?:[0-5][0-9]|60)\ (?:\\.[0-9]{1,6})?\ - Z?" + (?:Z|[+-](?:2[0-3]|[01][0-9]):[0-5][0-9])?" file_relative: display_name: Path relative to the parent file description: | diff --git a/tools/schemacode/src/bidsschematools/tests/test_schema.py b/tools/schemacode/src/bidsschematools/tests/test_schema.py index 6b1449e13e..e37493bb6c 100644 --- a/tools/schemacode/src/bidsschematools/tests/test_schema.py +++ b/tools/schemacode/src/bidsschematools/tests/test_schema.py @@ -87,6 +87,8 @@ def test_formats(schema_obj): "2022-01-05T13:16:30.000005", # up to 6 decimal points "2022-01-05T13:16:30Z", # UTC indicator is allowed "2022-01-05T13:16:30.05Z", + "2022-01-05T13:16:30+01:00", # integral offsets are allowed + "2022-01-05T13:16:30-05:00", ], "time": [ "13:16:30",