File: stdlib-times.md

package info (click to toggle)
golang-github-d5-tengo 2.17.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,240 kB
  • sloc: makefile: 12
file content (124 lines) | stat: -rw-r--r-- 6,221 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Module - "times"

```golang
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.
- `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_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".
- `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.