Skip to content

Commit

Permalink
clarification
Browse files Browse the repository at this point in the history
  • Loading branch information
khieta committed Aug 26, 2024
1 parent d3f335c commit fcdac27
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions text/0080-datetime-extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ Values of type `datetime` can also be used with the `-` operator.

An invariant for the `-` operator is that when `DT1` is before `DT2` the resulting duration is negative.

`DT1` may be negative (_i.e._ milliseconds _before_ `1970-01-01T00:00:00Z`) requiring that `-` be computed specially:
The internal representation of `DT1` may be negative (_i.e._ representing milliseconds _before_ `1970-01-01T00:00:00Z`) requiring that `-` be computed specially:

```
```cedar
if DT1 < 0 && DT2 >= 0 then
result = -(DT1 - DT2)
else
Expand All @@ -173,12 +173,11 @@ Values of type `datetime` can be used with comparison operators:

Equality is based on the underlying representation (see below) so, for example, `datetime("2024-08-21T") == datetime("2024-08-21T00:00:00.000Z")` is true. This behavior is consistent with the decimal extension function, where `decimal("1.0") == decimal("1.0000")` is also true.


#### Representation

The `datetime` type is internally represented as a `long` and contains a Unix Time in milliseconds. This is the number of non-leap seconds that have passed since `1970-01-01T00:00:00Z` in milliseconds. Unix Time days are always 86,400 seconds and handle leap seconds by absorbing them at the start of the day. Due to using Unix Time, and not providing a "current time" function, Cedar avoids the complexities of leap second handling, pushing them to the system and application.

Negative Unix Time values represent the number of milliseconds before `1970-01-01T00:00:00Z`.
Negative Unix Time values represent the number of milliseconds before `1970-01-01T00:00:00Z`.

### Durations of Time (`duration`)

Expand Down

0 comments on commit fcdac27

Please sign in to comment.