Skip to content

Commit ac1e8f8

Browse files
authored
Add more readable datetime literal examples (#1014)
## Goal We've done a pass over our date & time literal examples to keep them as intuitive as possible ## Implementation Split date & datetime examples into two blocks - one block for literals without the leading + symbol to denote a non-four-digit year - this is the default that everyone should expect & be used to - and we separate out the examples with a leading + into a separate clearly indicated block For example: ``` Example date literals 2024-03-30 1920-09-21 #!test[read] #{{ match let $x = 2024-03-30; let $y = 1920-09-21; #}} Example date literals (non-4-digit year) +20000-01-01 +900-09-21 #!test[read] #{{ match let $x = +20000-01-01; let $y = +900-09-21; #}} ```
1 parent 192563f commit ac1e8f8

File tree

4 files changed

+49
-12
lines changed

4 files changed

+49
-12
lines changed

typeql-reference/modules/ROOT/pages/values/date.adoc

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= Date
22
:test-typeql: linear
33

4-
An ISO 8601 compliant date type.
4+
An https://www.iso.org/iso-8601-date-and-time-format.html[ISO 8601,window=_blank] compliant date type.
55
66
== Syntax
77
@@ -15,12 +15,25 @@ The date literal consists of the following values, separated by a `-`:
1515
.Example date literals
1616
----
1717
2024-03-30
18-
+12345-09-21
18+
1920-09-21
1919
#!test[read]
2020
#{{
2121
match
2222
let $x = 2024-03-30;
23-
let $y = +12345-09-21;
23+
let $y = 1920-09-21;
24+
#}}
25+
----
26+
27+
[,typeql]
28+
.Example date literals (non-4-digit year)
29+
----
30+
+20000-01-01
31+
+900-09-21
32+
#!test[read]
33+
#{{
34+
match
35+
let $x = +20000-01-01;
36+
let $y = +900-09-21;
2437
#}}
2538
----
2639

typeql-reference/modules/ROOT/pages/values/datetime.adoc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= Datetime
22
:test-typeql: linear
33

4-
An ISO 8601 compliant date and time type.
4+
An https://www.iso.org/iso-8601-date-and-time-format.html[ISO 8601,window=_blank] compliant date and time type.
55
66
== Syntax
77
@@ -23,13 +23,27 @@ The time fragment consists of the following values, separated by `:`:
2323
.Example datetime literals
2424
----
2525
2024-03-30T12:00:00
26-
+12345-09-21T12:34:56.789
26+
1920-09-21T09:00:00
2727
2828
#!test[read]
2929
#{{
3030
match
3131
let $x = 2024-03-30T12:00:00;
32-
let $y = +12345-09-21T12:34:56.789;
32+
let $y = 1920-09-21T09:00:00;
33+
#}}
34+
----
35+
36+
[,typeql]
37+
.Example datetime literals (non-4-digit year)
38+
----
39+
+20000-01-01T10:30:00.000
40+
+900-09-21T19:59:59.358
41+
42+
#!test[read]
43+
#{{
44+
match
45+
let $x = +20000-01-01T10:30:00.000;
46+
let $y = +900-09-21T19:59:59.358;
3347
#}}
3448
----
3549

typeql-reference/modules/ROOT/pages/values/datetimetz.adoc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= DatetimeTZ
22
:test-typeql: linear
33

4-
An ISO 8601 compliant date and time type with time zone information.
4+
An https://www.iso.org/iso-8601-date-and-time-format.html[ISO 8601,window=_blank] compliant date and time type with time zone information.
55
66
== Syntax
77
@@ -19,20 +19,30 @@ The IANA TZ identifier is separated from the datetime by a space character.
1919
.Example datetime-tz literals
2020
----
2121
2024-03-30T12:00:00Z
22-
+12345-09-21T12:34:56.789+0100
23-
1887-12-22T17:29 Asia/Kolkata
22+
1987-12-22T17:29 Asia/Kolkata
2423
1920-04-26T16:30-09:30
2524
2625
#!test[read]
2726
#{{
2827
match
2928
let $w = 2024-03-30T12:00:00Z;
30-
let $x = +12345-09-21T12:34:56.789+0100;
3129
let $y = 1887-12-22T17:29 Asia/Kolkata;
3230
let $z = 1920-04-26T16:30-09:30;
3331
#}}
3432
----
3533
34+
[,typeql]
35+
.Example datetime-tz literal (non-4-digit year)
36+
----
37+
+20000-01-01T10:30:00.000
38+
39+
#!test[read]
40+
#{{
41+
match
42+
let $x = +20000-01-01T10:30:00.000+0100;
43+
#}}
44+
----
45+
3646
== Defining a datetime-tz valued attribute
3747
3848
[,typeql]
@@ -48,5 +58,5 @@ define
4858
----
4959
#!test[write]
5060
insert
51-
$_ isa scheduled-meeting-time 2025-01-10T12:34:56 Europe/London;
61+
$_ isa scheduled-meeting-time 2025-01-10T12:30:00 Europe/London;
5262
----

typeql-reference/modules/ROOT/pages/values/duration.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
= Duration
22
:test-typeql: linear
33

4-
An ISO 8601 compliant duration type.
4+
An https://www.iso.org/iso-8601-date-and-time-format.html[ISO 8601,window=_blank] compliant duration type.
55
66
== Syntax
77

0 commit comments

Comments
 (0)