14.6 Time
procedure
procedure
Example: | ||
|
In this example, 1289513737015 is in milliseconds and 418 is in microseconds.
procedure
(seconds->date secs-n [local-time?]) → date*?
secs-n : real? local-time? : any/c = #t
The resulting date* reflects the time according to the local time zone if local-time? is #t, otherwise it reflects a date in UTC.
struct
(struct date ( second minute hour day month year week-day year-day dst? time-zone-offset) #:extra-constructor-name make-date #:transparent) second : (integer-in 0 60) minute : (integer-in 0 59) hour : (integer-in 0 23) day : (integer-in 1 31) month : (integer-in 1 12) year : exact-integer? week-day : (integer-in 0 6) year-day : (integer-in 0 365) dst? : boolean? time-zone-offset : exact-integer?
The dst? field is #t if the date reflects a daylight-saving adjustment. The time-zone-offset field reports the number of seconds east of UTC (GMT) for the current time zone (e.g., Pacific Standard Time is -28800), including any daylight-saving adjustment (e.g., Pacific Daylight Time is -25200). When a date record is generated by seconds->date with #f as the second argument, then the dst? and time-zone-offset fields are #f and 0, respectively.
The date constructor accepts any value for dst? and converts any non-#f value to #t.
The value produced for the time-zone-offset field tends to be sensitive to the value of the TZ environment variable, especially on Unix platforms; consult the system documentation (usually under tzset) for details.
See also the racket/date library.
struct
(struct date* date (nanosecond time-zone-name) #:extra-constructor-name make-date*) nanosecond : (integer-in 0 999999999) time-zone-name : (and/c string? immutable?)
When a date* record is generated by seconds->date with #f as the second argument, then the time-zone-name field is "UTC".
The date* constructor accepts a mutable string for time-zone-name and converts it to an immutable one.
procedure
procedure
(current-process-milliseconds thread) → exact-integer?
thread : (or/c thread? #f)
procedure
procedure
(time-apply proc lst) →
list? exact-integer? exact-integer? exact-integer? proc : procedure? lst : list?
Four values are returned: a list containing the result(s) of applying proc to the arguments in lst, the number of milliseconds of CPU time required to obtain this result, the number of “real” milliseconds required for the result, and the number of milliseconds of CPU time (included in the first result) spent on garbage collection.
The reliability of the timing numbers depends on the platform. If multiple Racket threads are running, then the reported time may include work performed by other threads.
syntax
(time body ...+)
14.6.1 Date Utilities
procedure
(current-date) → date*?
procedure
(date->string date [time?]) → string?
date : date? time? : any/c = #f
parameter
(date-display-format) →
(or/c 'american 'chinese 'german 'indian 'irish 'iso-8601 'rfc2822 'julian) (date-display-format format) → void?
format :
(or/c 'american 'chinese 'german 'indian 'irish 'iso-8601 'rfc2822 'julian)
procedure
(date->seconds date [local-time?]) → exact-integer?
date : date? local-time? : any/c = #t
The week-day, year-day fields of date are ignored. The dst? and time-zone-offset fields of date are also ignored; the date is assumed to be in local time by default or in UTC if local-time? is #f.
procedure
(date*->seconds date [local-time?]) → real?
date : date? local-time? : any/c = #t
procedure
(find-seconds second minute hour day month year [ local-time?]) → exact-integer? second : (integer-in 0 61) minute : (integer-in 0 59) hour : (integer-in 0 23) day : (integer-in 1 31) month : (integer-in 1 12) year : exact-nonnegative-integer? local-time? : any/c = #t
procedure
(date->julian/scalinger date) → exact-integer?
date : date?
procedure
(julian/scalinger->string date-number) → string?
date-number : exact-integer?