Skip to content

Commit d5d4467

Browse files
authored
Merge pull request #2002 from effigies/fix/datetime-offsets
fix: Update datetime definition/regex to match specification
2 parents c17b7f3 + 37dacf6 commit d5d4467

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

src/schema/objects/formats.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,18 @@ datetime:
7070
display_name: Datetime
7171
description: |
7272
A datetime in the form `"YYYY-MM-DDThh:mm:ss[.000000][Z]"`,
73-
where [.000000] is an optional subsecond resolution between 1 and 6 decimal points,
74-
and [Z] is an optional, valid timezone code.
75-
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})?'
73+
where `[.000000]` is an optional subsecond resolution between 1 and 6 decimal points,
74+
and `[Z]` is an optional literal character `Z` that indicates
75+
Coordinated Universal Time (UTC).
76+
pattern: "\
77+
[0-9]{4}\
78+
-(?:0[1-9]|1[0-2])\
79+
-(?:0[1-9]|[12][0-9]|3[01])\
80+
T(?:2[0-3]|[01][0-9])\
81+
:[0-5][0-9]\
82+
:(?:[0-5][0-9]|60)\
83+
(?:\\.[0-9]{1,6})?\
84+
Z?"
7685
file_relative:
7786
display_name: Path relative to the parent file
7887
description: |

src/schema/objects/metadata.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2899,10 +2899,10 @@ RepetitionTime:
28992899
and the beginning of acquisition of the volume following it (TR).
29002900
When used in the context of functional acquisitions this parameter best
29012901
corresponds to
2902-
[DICOM Tag 0020, 0110](http://dicomlookup.com/dicomtags/(0020,0110)):
2902+
[DICOM Tag 0020, 0110](https://dicomlookup.com/dicomtags/(0020,0110)):
29032903
the "time delta between images in a
29042904
dynamic of functional set of images" but may also be found in
2905-
[DICOM Tag 0018, 0080](http://dicomlookup.com/dicomtags/(0018,0080)):
2905+
[DICOM Tag 0018, 0080](https://dicomlookup.com/dicomtags/(0018,0080)):
29062906
"the period of time in msec between the beginning
29072907
of a pulse sequence and the beginning of the succeeding
29082908
(essentially identical) pulse sequence".
@@ -2919,7 +2919,7 @@ RepetitionTimeExcitation:
29192919
display_name: Repetition Time Excitation
29202920
description: |
29212921
The interval, in seconds, between two successive excitations.
2922-
[DICOM Tag 0018, 0080](http://dicomlookup.com/dicomtags/(0018,0080))
2922+
[DICOM Tag 0018, 0080](https://dicomlookup.com/dicomtags/(0018,0080))
29232923
best refers to this parameter.
29242924
This field may be used together with the `"RepetitionTimePreparation"` for
29252925
certain use cases, such as

tools/schemacode/src/bidsschematools/tests/test_schema.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def test_formats(schema_obj):
8585
"2022-01-05T13:16:30",
8686
"2022-01-05T13:16:30.5", # subsecond resolution is allowed
8787
"2022-01-05T13:16:30.000005", # up to 6 decimal points
88-
"2022-01-05T13:16:30UTC", # timezones are allowed
89-
"2022-01-05T13:16:30.05UTC",
88+
"2022-01-05T13:16:30Z", # UTC indicator is allowed
89+
"2022-01-05T13:16:30.05Z",
9090
],
9191
"time": [
9292
"13:16:30",
@@ -133,7 +133,7 @@ def test_formats(schema_obj):
133133
],
134134
"datetime": [
135135
"2022-01-05T13:16:30.1000005", # too many decimal points
136-
"2022-01-05T13:16:30U", # time zone too short
136+
"2022-01-05T13:16:30U", # Only Z is permitted
137137
"2022-01-05T13:16:30UTCUTC", # time zone too long
138138
"2022-01-05T34:10:10", # invalid time
139139
],

0 commit comments

Comments
 (0)