4 Combined Date and Time
The datetime struct represents the combination of a date and a time; that is, it represents a date at a particular time-of-day. However, it does not include time zone information, so it does not represent an absolute moment in time.
procedure
(datetime year [ month day hour minute second nanosecond]) → datetime? year : exact-integer? month : (integer-in 1 12) = 1 day : (day-of-month/c year month) = 1 hour : (integer-in 0 23) = 0 minute : (integer-in 0 59) = 0 second : (integer-in 0 59) = 0 nanosecond : (integer-in 0 999999999) = 0
> (datetime 1970) #<datetime 1970-01-01T00:00:00>
> (datetime 1969 7 21 2 56) #<datetime 1969-07-21T02:56:00>
procedure
(jd->datetime jd) → datetime?
jd : real?
> (jd->datetime 0) #<datetime -4713-11-24T12:00:00>
> (jd->datetime 2440587.5) #<datetime 1970-01-01T00:00:00>
procedure
(posix->datetime posix) → datetime?
posix : real?
> (posix->datetime 0) #<datetime 1970-01-01T00:00:00>
> (posix->datetime 2147483648) #<datetime 2038-01-19T03:14:08>
procedure
(datetime->iso8601 dt) → string?
dt : datetime?
> (datetime->iso8601 (datetime 1970)) "1970-01-01T00:00:00"
> (datetime->iso8601 (datetime 1969 7 21 2 56)) "1969-07-21T02:56:00"
> (datetime->iso8601 (datetime 1 2 3 4 5 6 7)) "0001-02-03T04:05:06.000000007"
procedure
(datetime=? x y) → boolean?
x : datetime? y : datetime?
procedure
(datetime<? x y) → boolean?
x : datetime? y : datetime?
procedure
(datetime<=? x y) → boolean?
x : datetime? y : datetime?
procedure
(datetime>? x y) → boolean?
x : datetime? y : datetime?
procedure
(datetime>=? x y) → boolean?
x : datetime? y : datetime?
> (datetime=? (datetime 1970 1 1) (datetime 1970)) #t
> (datetime<? (datetime 1970) (datetime 1969 7 21 2 56)) #f
> (datetime>? (datetime 1970) (datetime 1969 7 21 2 56)) #t
value
> (datetime-order (datetime 1970 1 1) (datetime 1970)) '=
> (datetime-order (datetime 1970) (datetime 1969 7 21 2 56)) '>
> (datetime-order (datetime 1969 7 21 2 56) (datetime 1970)) '<
> (make-splay-tree datetime-order) #<splay-tree*>