Factry Historian
...
Standard Library
times
module "times" tengo times = import("times") constants format ansic time format "mon jan 2 15 04 05 2006" format unix date time format "mon jan 2 15 04 05 mst 2006" format ruby date time format "mon jan 02 15 04 05 0700 2006" format rfc822 time format "02 jan 06 15 04 mst" format rfc822z time format "02 jan 06 15 04 0700" format rfc850 time format "monday, 02 jan 06 15 04 05 mst" format rfc1123 time format "mon, 02 jan 2006 15 04 05 mst" format rfc1123z time format "mon, 02 jan 2006 15 04 05 0700" format rfc3339 time format "2006 01 02t15 04 05z07 00" format rfc3339 nano time format "2006 01 02t15 04 05 999999999z07 00" format kitchen time format "3 04pm" format stamp time format "jan 2 15 04 05" format stamp milli time format "jan 2 15 04 05 000" format stamp micro time format "jan 2 15 04 05 000000" format stamp nano time format "jan 2 15 04 05 000000000" nanosecond microsecond millisecond second minute hour january february march april may june july august september october november december functions sleep(duration int) pauses the current goroutine for at least the duration d a negative or zero duration causes sleep to return immediately parse duration(s string) => int parses a duration string a duration string is a possibly signed sequence of decimal numbers, 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" since(t time) => int returns the time elapsed since t until(t time) => int returns the duration until t duration hours(duration int) => float returns the duration as a floating point number of hours duration minutes(duration int) => float returns the duration as a floating point number of minutes duration nanoseconds(duration int) => int returns the duration as an integer of nanoseconds duration seconds(duration int) => float returns the duration as a floating point number of seconds duration string(duration int) => string returns a string representation of duration month string(month int) => string returns the english name of the month ("january", "february", ) date(year int, month int, day int, hour int, min int, sec int, nsec int, loc string) => time returns the time corresponding to "yyyy mm dd hh\ mm\ ss + nsec nanoseconds" in the appropriate zone for that time in the given (optional) location the local time zone will be used if executed without specifying a location now() => time returns the current local time parse(format string, s string) => time parses a formatted string and returns the time value it represents the layout defines the format by showing how the reference time, defined to be "mon jan 2 15 04 05 0700 mst 2006" would be interpreted if it were the value; it serves as an example of the input format the same interpretation will then be made to the input string parseinlocation(format string, s string, loc string) parseinlocation is like parse but parse interprets a time as utc; parseinlocation interprets the time as in the given location unix(sec int, nsec int) => time returns the local time corresponding to the given unix time, sec seconds and nsec nanoseconds since january 1, 1970 utc add(t time, duration int) => time returns the time t+d add date(t time, years int, months int, days int) => time returns the time corresponding to adding the given number of years, months, and days to t for example, adddate( 1, 2, 3) applied to january 1, 2011 returns march 4, 2010 sub(t time, u time) => int returns the duration t u after(t time, u time) => bool reports whether the time instant t is after u before(t time, u time) => bool reports whether the time instant t is before u time year(t time) => int returns the year in which t occurs time month(t time) => int returns the month of the year specified by t time day(t time) => int returns the day of the month specified by t time weekday(t time) => int returns the day of the week specified by t time yearday(t time) => int returns the day of the year specified by t, in the range \[1,365] for non leap years, and \[1,366] in leap years time hour(t time) => int returns the hour within the day specified by t, in the range \[0, 23] time minute(t time) => int returns the minute offset within the hour specified by t, in the range \[0, 59] time second(t time) => int returns the second offset within the minute specified by t, in the range \[0, 59] time nanosecond(t time) => int returns the nanosecond offset within the second specified by t, in the range \[0, 999999999] time unix(t time) => int returns t as a unix time, the number of seconds elapsed since january 1, 1970 utc the result does not depend on the location associated with t time unix nano(t time) => int returns t as a unix time, the number of nanoseconds elapsed since january 1, 1970 utc the result is undefined if the unix time in nanoseconds cannot be represented by an int64 (a date before the year 1678 or after 2262) note that this means the result of calling unixnano on the zero time is undefined the result does not depend on the location associated with t time format(t time, format) => string returns a textual representation of he time value formatted according to layout, 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 time location(t time) => string returns the time zone name associated with t time string(t time) => string returns the time formatted using the format string "2006 01 02 15 04 05 999999999 0700 mst" to location(t time, loc string) returns a copy of t representing the same time instant, but with the copy's location information set to loc for display purposes is dst(t time) reports whether the time in the configured location is in daylight savings time is zero(t time) => bool reports whether t represents the zero time instant, january 1, year 1, 00 00 00 utc in location(t time, l string) => time returns a copy of t representing the same time instant, but with the copy's location information set to l for display purposes to local(t time) => time returns t with the location set to local time to utc(t time) => time returns t with the location set to utc