3 Time-of-Day
(require gregor/time) | package: gregor-lib |
Gregor’s time struct represents a time-of-day, irrespective of date or time zone. As with Gregor’s date struct, the name time also conflicts with an existing, incompatible definition in racket/base. The situation here is somewhat different, however. While Gregor completely replaces the functionality offered by the built-in date, it does not replace that of the built-in time function, which is used for measuring the time spent evaluating programs.
To mitigate problems that might be caused by this conflict, Gregor does not provide time-related bindings from the gregor module. Instead, they are provided by the gregor/time module.
procedure
hour : (integer-in 0 23) minute : (integer-in 0 59) = 0 second : (integer-in 0 59) = 0 nanosecond : (integer-in 0 999999999) = 0
Note the contract on second; a time is unable to represent times that fall on added UTC leap-seconds. For a discussion of Gregor’s relationship to UTC, see Time Scale.
procedure
(time->iso8601 t) → string?
t : time?
> (time->iso8601 (time 1 2 3 4)) "01:02:03.000000004"
> (time->iso8601 (time 0)) "00:00:00"
> (time->iso8601 (time 12)) "12:00:00"
procedure
x : time? y : time?
procedure
x : time? y : time?
procedure
x : time? y : time?
procedure
x : time? y : time?
procedure
x : time? y : time?
> (time=? (time 12 0 0) (time 12)) #t
> (time<? (time 1 30) (time 13 30)) #t
> (time>? (time 1 2 3 4) (time 1 2 3)) #t
value
> (time-order (time 12 0 0) (time 12)) '=
> (time-order (time 1 30) (time 13 30)) '<
> (time-order (time 1 2 3 4) (time 1 2 3)) '>
> (make-splay-tree time-order) #<compact-splay-tree*>