Namespace: joker.time
v1.0Contents
Summary
Creates, parses, formats, compares, and converts times and nanosecond durations.
Index
- add
- add-date
- ansi-c
- day-of-year
- format
- from-unix
- hour
- hours
- in-timezone
- kitchen
- microsecond
- millisecond
- minute
- minutes
- nanosecond
- now
- parse
- parse-duration
- parse-in-timezone
- rfc1123
- rfc1123-z
- rfc3339
- rfc3339-nano
- rfc822
- rfc822-z
- rfc850
- round
- ruby-date
- second
- seconds
- since
- sleep
- stamp
- stamp-micro
- stamp-milli
- stamp-nano
- string
- sub
- truncate
- unix
- unix-date
- until
Constants
Constants are variables with :const true in their metadata. Joker currently does not recognize them as special; as such, it allows redefining them or their values.-
ansi-c
String v1.0Mon Jan _2 15:04:05 2006
-
hour
BigInt v1.0Number of nanoseconds in 1 hour
-
kitchen
String v1.03:04PM
-
microsecond
Int v1.0Number of nanoseconds in 1 microsecond
-
millisecond
Int v1.0Number of nanoseconds in 1 millisecond
-
minute
BigInt v1.0Number of nanoseconds in 1 minute
-
nanosecond
Int v1.0Number of nanoseconds in 1 nanosecond
-
rfc1123
String v1.0Mon, 02 Jan 2006 15:04:05 MST
-
rfc1123-z
String v1.0Mon, 02 Jan 2006 15:04:05 -0700
-
rfc3339
String v1.02006-01-02T15:04:05Z07:00
-
rfc3339-nano
String v1.02006-01-02T15:04:05.999999999Z07:00
-
rfc822
String v1.002 Jan 06 15:04 MST
-
rfc822-z
String v1.002 Jan 06 15:04 -0700
-
rfc850
String v1.0Monday, 02-Jan-06 15:04:05 MST
-
ruby-date
String v1.0Mon Jan 02 15:04:05 -0700 2006
-
second
Int v1.0Number of nanoseconds in 1 second
-
stamp
String v1.0Jan _2 15:04:05
-
stamp-micro
String v1.0Jan _2 15:04:05.000000
-
stamp-milli
String v1.0Jan _2 15:04:05.000
-
stamp-nano
String v1.0Jan _2 15:04:05.000000000
-
unix-date
String v1.0Mon Jan _2 15:04:05 MST 2006
Variables
-
(None.)
Functions, Macros, and Special Forms
-
add
Function v1.0(add t d)(add ^Time t ^Integer d)Returns the time t+d.
show types -
add-date
Function v1.0(add-date t years months days)(add-date ^Time t ^Integer years ^Integer months ^Integer days)Returns the time t + (years, months, days).
show types -
day-of-year
Function v1.3.4(day-of-year t)(day-of-year ^Time t)Returns the day of the year specified by t, in the range [1,365] for non-leap years, and [1,366] in leap years.
show types -
format
Function v1.0(format t layout)(format ^Time t ^String layout)Returns a textual representation of the time value formatted according to layout,
show types
which defines the format by showing how the reference time, defined to be
Mon Jan 2 15:04:05 -0700 MST 2006
would be displayed if it were the value; it serves as an example of the desired output.
The same display rules will then be applied to the time value. -
from-unix
Function v1.0(from-unix sec nsec)(from-unix ^Integer sec ^Integer nsec)Returns the local Time corresponding to the given Unix time, sec seconds and
show types
nsec nanoseconds since January 1, 1970 UTC. It is valid to pass nsec outside the range [0, 999999999]. -
hours
Function v1.0(hours d)(hours ^Integer d)Returns the duration (passed as a number of nanoseconds) as a floating point number of hours.
show types -
in-timezone
Function v1.0(in-timezone t tz)(in-timezone ^Time t ^String tz)Returns t represented in timezone tz.
show types
The instant is unchanged; only the location used for display and calendar
fields changes. tz must be a loadable IANA timezone name. Throws Error when
tz cannot be loaded. -
minutes
Function v1.0(minutes d)(minutes ^Integer d)Returns the duration (passed as a number of nanoseconds) as a floating point number of minutes.
show types -
now
Function v1.0(now)Returns the current local time.
-
parse
Function v1.0(parse layout value)(parse ^String layout ^String value)Parses value according to layout and returns a Time.
show types
layout uses Go's reference-time convention. When value contains no zone
information, parsing uses UTC. Throws Error when value does not match layout. -
parse-duration
Function v1.0(parse-duration s)(parse-duration ^String s)Parses a duration string. A duration string is a possibly signed sequence of decimal numbers,
show types
each with optional fraction and a unit suffix, such as 300ms, -1.5h or 2h45m. Valid time units are
ns, us (or µs), ms, s, m, h. -
parse-in-timezone
Function v1.7.2(parse-in-timezone layout value tz)(parse-in-timezone ^String layout ^String value ^String tz)Parses value according to layout in timezone tz and returns a Time.
show types
tz must be a loadable IANA timezone name such as "America/New_York".
Throws Error when tz cannot be loaded or value does not match layout. -
round
Function v1.0(round d m)(round ^Integer d ^Integer m)Returns the result of rounding d to the nearest multiple of m. d and m represent time durations in nanoseconds.
show types
The rounding behavior for halfway values is to round away from zero. If m <= 0, returns d unchanged. -
seconds
Function v1.0(seconds d)(seconds ^Integer d)Returns the duration (passed as a number of nanoseconds) as a floating point number of seconds.
show types -
since
Function v1.0(since t)(since ^Time t)Returns the time in nanoseconds elapsed since t.
show types -
sleep
Function v1.0(sleep d)(sleep ^Integer d)Pauses the execution thread for at least the duration d (expressed in nanoseconds).
show types
A negative or zero duration causes sleep to return immediately. -
string
Function v1.0(string d)(string ^Integer d)Returns a string representing the duration in the form 72h3m0.5s.
show types -
sub
Function v1.0(sub t u)(sub ^Time t ^Time u)Returns the duration t-u in nanoseconds.
show types -
truncate
Function v1.0(truncate d m)(truncate ^Integer d ^Integer m)Returns the result of rounding d toward zero to a multiple of m. If m <= 0, returns d unchanged.
show types -
unix
Function v1.0(unix t)(unix ^Time t)Returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC.
show types -
until
Function v1.0(until t)(until ^Time t)Returns the duration in nanoseconds until t.
show types