15.6 Time
procedure
procedure
> (current-inexact-milliseconds) 1289513737015.418
In this example, 1289513737015 is in milliseconds and 418 is in microseconds.
procedure
> (current-inexact-monotonic-milliseconds) 12772.418
Added in version 8.1.0.4 of package base.
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 [scope]) → exact-integer?
scope : (or/c #f thread? 'subprocesses) = #f
If scope is #f, the reported time is for all Racket threads and places.
If scope is a thread, the result is specific to the time while the thread ran, but it may include time for other places. The more a thread synchronizes with other threads, the less precisely per-thread processor time is recorded.
If scope is 'subprocesses, the result is the sum of process times for known-completed subprocesses (see Processes)—
and known-completed children of the subprocesses, etc., on Unix and Mac OS— across all places.
The precision of the result is platform-specific, and since the result is a fixnum, the value increases only over a limited (though reasonably long) time on a 32-bit platform.
Changed in version 6.1.1.4 of package base: Added 'subprocesses mode.
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 ...+)
15.6.1 Date Utilities
For more date & time operations, see the Gregor: Date and Time documentation or srfi/19
(require racket/date) | package: base |
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/scaliger date) → exact-integer?
date : date?
procedure
(julian/scaliger->string date-number) → string?
date-number : exact-integer?
procedure
(date->julian/scalinger date) → exact-integer?
date : date?
procedure
(julian/scalinger->string date-number) → string?
date-number : exact-integer?