added unix timestamp support to date functions, resolves #1163
parent
f4a00c9bfe
commit
2271fb1b3a
|
@ -29,10 +29,11 @@ date.hour(t: 2019-07-17T12:05:21.012Z)
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -55,3 +56,12 @@ date.hour(t: -8h)
|
||||||
|
|
||||||
// Returns 4
|
// Returns 4
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return the hour of a nanosecond Unix timestamp
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.hour(t: 1581423663293534940)
|
||||||
|
|
||||||
|
// Returns 12
|
||||||
|
```
|
||||||
|
|
|
@ -29,10 +29,11 @@ date.microsecond(t: 2019-07-17T12:05:21.012934584Z)
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -55,3 +56,12 @@ date.microsecond(t: -1890us)
|
||||||
|
|
||||||
// Returns 291644
|
// Returns 291644
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return the microsecond of a nanosecond Unix timestamp
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.microsecond(t: 1581423663293534940)
|
||||||
|
|
||||||
|
// Returns 293534
|
||||||
|
```
|
||||||
|
|
|
@ -29,10 +29,11 @@ date.millisecond(t: 2019-07-17T12:05:21.012934584Z)
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -55,3 +56,12 @@ date.millisecond(t: -150ms)
|
||||||
|
|
||||||
// Returns 143
|
// Returns 143
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return the millisecond of a nanosecond Unix timestamp
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.millisecond(t: 1581423663293534940)
|
||||||
|
|
||||||
|
// Returns 293
|
||||||
|
```
|
||||||
|
|
|
@ -29,10 +29,11 @@ date.minute(t: 2019-07-17T12:05:21.012Z)
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -55,3 +56,12 @@ date.minute(t: -45m)
|
||||||
|
|
||||||
// Returns 36
|
// Returns 36
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return the minute of a nanosecond Unix timestamp
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.minute(t: 1581423663293534940)
|
||||||
|
|
||||||
|
// Returns 21
|
||||||
|
```
|
||||||
|
|
|
@ -29,10 +29,11 @@ date.month(t: 2019-07-17T12:05:21.012Z)
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -55,3 +56,12 @@ date.month(t: -3mo)
|
||||||
|
|
||||||
// Returns 11
|
// Returns 11
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return the month of a nanosecond Unix timestamp
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.month(t: 1581423663293534940)
|
||||||
|
|
||||||
|
// Returns 2
|
||||||
|
```
|
||||||
|
|
|
@ -29,10 +29,11 @@ date.monthDay(t: 2019-07-17T12:05:21.012Z)
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -55,3 +56,12 @@ date.monthDay(t: -8d)
|
||||||
|
|
||||||
// Returns 3
|
// Returns 3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return the day of the month for a nanosecond Unix timestamp
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.monthDay(t: 1581423663293534940)
|
||||||
|
|
||||||
|
// Returns 11
|
||||||
|
```
|
||||||
|
|
|
@ -29,10 +29,11 @@ date.nanosecond(t: 2019-07-17T12:05:21.012934584Z)
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -55,3 +56,12 @@ date.nanosecond(t: -2111984ns)
|
||||||
|
|
||||||
// Returns 291422956
|
// Returns 291422956
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return the nanosecond for a nanosecond Unix timestamp
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.nanosecond(t: 1581423663293534940)
|
||||||
|
|
||||||
|
// Returns 293534940Z
|
||||||
|
```
|
||||||
|
|
|
@ -29,10 +29,11 @@ date.quarter(t: 2019-07-17T12:05:21.012Z)
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -55,3 +56,12 @@ date.quarter(t: -7mo)
|
||||||
|
|
||||||
// Returns 3
|
// Returns 3
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return the quarter for a nanosecond Unix timestamp
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.quarter(t: 1581423663293534940)
|
||||||
|
|
||||||
|
// Returns 1
|
||||||
|
```
|
||||||
|
|
|
@ -29,10 +29,11 @@ date.second(t: 2019-07-17T12:05:21.012Z)
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -55,3 +56,12 @@ date.second(t: -50s)
|
||||||
|
|
||||||
// Returns 13
|
// Returns 13
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return the second of a nanosecond Unix timestamp
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.second(t: 1581423663293534940)
|
||||||
|
|
||||||
|
// Returns 3
|
||||||
|
```
|
||||||
|
|
|
@ -30,10 +30,11 @@ date.truncate(
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
### unit
|
### unit
|
||||||
The unit of time to truncate to.
|
The unit of time to truncate to.
|
||||||
|
@ -76,3 +77,17 @@ date.truncate(t: -1m, unit: 1m)
|
||||||
date.truncate(t: -1h, unit: 1h)
|
date.truncate(t: -1h, unit: 1h)
|
||||||
// Returns 2019-12-31T23:00:00.000000000Z
|
// Returns 2019-12-31T23:00:00.000000000Z
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Truncate time values using nanosecond Unix timestamps
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.truncate(t: 1559570341000000000, unit: 1s)
|
||||||
|
// Returns 2019-06-03T13:59:01.000000000Z
|
||||||
|
|
||||||
|
date.truncate(t: 1559570341000000000, unit: 1m)
|
||||||
|
// Returns 2019-06-03T13:59:00.000000000Z
|
||||||
|
|
||||||
|
date.truncate(t: 1559570341000000000, unit: 1h)
|
||||||
|
// Returns 2019-06-03T13:00:00.000000000Z
|
||||||
|
```
|
||||||
|
|
|
@ -29,10 +29,11 @@ date.week(t: 2019-07-17T12:05:21.012Z)
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -55,3 +56,12 @@ date.week(t: -12d)
|
||||||
|
|
||||||
// Returns 5
|
// Returns 5
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return the week of the year using a nanosecond Unix timestamp
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.week(t: 1581423663293534940)
|
||||||
|
|
||||||
|
// Returns 7
|
||||||
|
```
|
||||||
|
|
|
@ -29,10 +29,11 @@ date.weekDay(t: 2019-07-17T12:05:21.012Z)
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -55,3 +56,12 @@ date.weekDay(t: -84h)
|
||||||
|
|
||||||
// Returns 6
|
// Returns 6
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return the day of the week for a nanosecond Unix timestamp
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.weekDay(t: 1581423663293534940)
|
||||||
|
|
||||||
|
// Returns 2
|
||||||
|
```
|
||||||
|
|
|
@ -27,10 +27,11 @@ date.year(t: 2019-07-17T12:05:21.012Z)
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -53,3 +54,12 @@ date.year(t: -14y)
|
||||||
|
|
||||||
// Returns 2006
|
// Returns 2006
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return the year for a nanosecond Unix timestamp
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.year(t: 1581423663293534940)
|
||||||
|
|
||||||
|
// Returns 2020
|
||||||
|
```
|
||||||
|
|
|
@ -29,10 +29,11 @@ date.yearDay(t: 2019-07-17T12:05:21.012Z)
|
||||||
|
|
||||||
### t
|
### t
|
||||||
The time to operate on.
|
The time to operate on.
|
||||||
Use an absolute time or relative duration.
|
Use an absolute time, relative duration, or integer.
|
||||||
Durations are relative to `now()`.
|
Durations are relative to `now()`.
|
||||||
|
Integers are **nanosecond** [Unix timestamps](/v2.0/reference/glossary/#unix-timestamp).
|
||||||
|
|
||||||
_**Data type:** Time | Duration_
|
_**Data type:** Time | Duration | Integer_
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
@ -55,3 +56,12 @@ date.yearDay(t: -1mo)
|
||||||
|
|
||||||
// Returns 11
|
// Returns 11
|
||||||
```
|
```
|
||||||
|
|
||||||
|
##### Return the day of the year for a nanosecond Unix timestamp
|
||||||
|
```js
|
||||||
|
import "date"
|
||||||
|
|
||||||
|
date.yearDay(t: 1581423663293534940)
|
||||||
|
|
||||||
|
// Returns 42
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue