Skip to content

Commit 70bcbd4

Browse files
Document duration arithmetic behaviour (#918)
## What is the goal of this PR? We document the edge case behaviour of datetime-tz arithmetic with durations as implemented in typedb/typedb#7329.
1 parent 0ae0488 commit 70bcbd4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,34 @@ When used with a value of type datetime-tz, arithmetic operations with duration
8787
2024-03-30T12:00:00 Europe/London + PT24H == 2024-03-31T13:00:00
8888
----
8989

90+
If adding months and days results in an ambiguous datetime in the time zone, the earlier datetime is used.
91+
92+
[,typeql]
93+
----
94+
# London DST change occurred on 2024-10-27 02:00:00 BST
95+
# I.e., on 2024-10-27, the time span between 01:00:00 and 02:00:00 occurs twice
96+
2024-10-26T01:30:00 Europe/London + P1D == 2024-10-27T01:30:00 BST
97+
98+
# Between these two local datetimes, the earliest is BST
99+
2024-10-26T01:30:00 Europe/London + PT24H == 2024-10-27T01:30:00 BST
100+
2024-10-26T01:30:00 Europe/London + PT25H == 2024-10-27T01:30:00 GMT
101+
----
102+
103+
If adding months and days results in a datetime that does not exist in the time zone, i.e. if there is a gap in the time zone, the datetime
104+
is increased by the length of the gap.
105+
106+
[,typeql]
107+
----
108+
# London DST change occurred on 2024-03-31 01:00:00 GMT
109+
# I.e., there is a gap on 2024-03-31 between 01:00:00 and 02:00:00
110+
2024-03-30T01:30:00 Europe/London + P1D == 2024-03-31T02:30:00 BST
111+
112+
# This is the same as adding 24 hours
113+
2024-03-30T01:30:00 Europe/London + PT24H == 2024-03-31T02:30:00 BST
114+
----
115+
116+
The nanosecond part of the duration is added directly to the underlying UTC timestamp, and as such requires no special handling.
117+
90118
=== Defining a duration valued attribute
91119

92120
[,typeql]

0 commit comments

Comments
 (0)