Merge pull request #335 from influxdata/flux/date-package

Flux date package
pull/353/head
Scott Anderson 2019-07-23 14:25:59 -06:00 committed by GitHub
commit af210afbd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 280 additions and 74 deletions

View File

@ -0,0 +1,59 @@
---
title: Flux date package
list_title: Date package
description: >
The Flux math package provides basic constants and mathematical functions.
Import the `math` package.
aliases:
- /v2.0/reference/flux/language/built-ins/time-constants/
menu:
v2_0_ref:
name: Date
parent: Flux packages and functions
weight: 202
v2.0/tags: [date, time, functions]
---
The Flux date package provides date and time constants and functions.
Import the `date` package.
```js
import "date"
```
## Date and time constants
That `date` package includes the following date and time constants.
### Days of the week
Days of the week are represented as integers in the range `[0-6]`.
```js
date.Sunday = 0
date.Monday = 1
date.Tuesday = 2
date.Wednesday = 3
date.Thursday = 4
date.Friday = 5
date.Saturday = 6
```
### Months of the year
Months are represented as integers in the range `[1-12]`.
```js
date.January = 1
date.February = 2
date.March = 3
date.April = 4
date.May = 5
date.June = 6
date.July = 7
date.August = 8
date.September = 9
date.October = 10
date.November = 11
date.December = 12
```
## Date and time functions
{{< children type="functions" show="pages" >}}

View File

@ -0,0 +1,31 @@
---
title: date.hour() function
description: >
The `date.hour()` function returns the hour of a specified time.
Results range from `[0-23]`.
menu:
v2_0_ref:
name: date.hour
parent: Date
weight: 301
---
The `date.hour()` function returns the hour of a specified time.
Results range from `[0-23]`.
_**Function type:** Transformation_
```js
import "date"
date.hour(t: 2019-07-17T12:05:21.012Z)
// Returns 12
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_

View File

@ -0,0 +1,31 @@
---
title: date.minute() function
description: >
The `date.minute()` function returns the minute of a specified time.
Results range from `[0-59]`.
menu:
v2_0_ref:
name: date.minute
parent: Date
weight: 301
---
The `date.minute()` function returns the minute of a specified time.
Results range from `[0-59]`.
_**Function type:** Transformation_
```js
import "date"
date.minute(t: 2019-07-17T12:05:21.012Z)
// Returns 21
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_

View File

@ -0,0 +1,31 @@
---
title: date.month() function
description: >
The `date.month()` function returns the month of a specified time.
Results range from `[1-12]`
menu:
v2_0_ref:
name: date.month
parent: Date
weight: 301
---
The `date.month()` function returns the month of a specified time.
Results range from `[1-12]`
_**Function type:** Transformation_
```js
import "date"
date.month(t: 2019-07-17T12:05:21.012Z)
// Returns 7
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_

View File

@ -0,0 +1,31 @@
---
title: date.monthDay() function
description: >
The `date.monthDay()` function returns the day of the month for a specified time.
Results range from `[1-31]`.
menu:
v2_0_ref:
name: date.monthDay
parent: Date
weight: 301
---
The `date.monthDay()` function returns the day of the month for a specified time.
Results range from `[1-31]`.
_**Function type:** Transformation_
```js
import "date"
date.monthDay(t: 2019-07-17T12:05:21.012Z)
// Returns 17
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_

View File

@ -0,0 +1,31 @@
---
title: date.second() function
description: >
The `date.second()` function returns the second of a specified time.
Results range from `[0-59]`.
menu:
v2_0_ref:
name: date.second
parent: Date
weight: 301
---
The `date.second()` function returns the second of a specified time.
Results range from `[0-59]`.
_**Function type:** Transformation_
```js
import "date"
date.second(t: 2019-07-17T12:05:21.012Z)
// Returns 21
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_

View File

@ -0,0 +1,31 @@
---
title: date.weekDay() function
description: >
The `date.weekDay()` function returns the day of the week for a specified time.
Results range from `[0-6]`.
menu:
v2_0_ref:
name: date.weekDay
parent: Date
weight: 301
---
The `date.weekDay()` function returns the day of the week for a specified time.
Results range from `[0-6]`.
_**Function type:** Transformation_
```js
import "date"
date.weekDay(t: 2019-07-17T12:05:21.012Z)
// Returns 3
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_

View File

@ -0,0 +1,31 @@
---
title: date.yearDay() function
description: >
The `date.yearDay()` function returns the day of the year for a specified time.
Results range from `[1-365]` for non-leap years, and `[1-366]` in leap years.
menu:
v2_0_ref:
name: date.yearDay
parent: Date
weight: 301
---
The `date.yearDay()` function returns the day of the year for a specified time.
Results include leap days and range from `[1-366]`.
_**Function type:** Transformation_
```js
import "date"
date.yearDay(t: 2019-07-17T12:05:21.012Z)
// Returns 198
```
## Parameters
### t
The time to operate on.
_**Data type:** Time_

View File

@ -1,16 +0,0 @@
---
title: Built-ins
description: >
Flux contains many preassigned values.
These preassigned values are defined in the source files for the various built-in packages.
menu:
v2_0_ref:
name: Built-ins
parent: Flux specification
weight: 208
---
Flux contains many preassigned values.
These preassigned values are defined in the source files for the various built-in packages.
{{< children >}}

View File

@ -1,56 +0,0 @@
---
title: Time constants
description: >
Flux provides built-in time constants for days of the week and months of the year.
menu:
v2_0_ref:
name: Time constants
parent: Built-ins
weight: 301
---
{{% note %}}
This document is a living document and may not represent the current implementation of Flux.
Any section that is not currently implemented is commented with a **[IMPL#XXX]** where
**XXX** is an issue number tracking discussion and progress towards implementation.
{{% /note %}}
## Days of the week
Days of the week are represented as integers in the range `[0-6]`.
The following builtin values are defined:
```js
Sunday = 0
Monday = 1
Tuesday = 2
Wednesday = 3
Thursday = 4
Friday = 5
Saturday = 6
```
{{% note %}}
[IMPL#153](https://github.com/influxdata/flux/issues/153) Add Days of the Week constants
{{% /note %}}
## Months of the year
Months are represented as integers in the range `[1-12]`.
The following builtin values are defined:
```js
January = 1
February = 2
March = 3
April = 4
May = 5
June = 6
July = 7
August = 8
September = 9
October = 10
November = 11
December = 12
```
{{% note %}}
[IMPL#154](https://github.com/influxdata/flux/issues/154) Add Months of the Year constants
{{% /note %}}

View File

@ -3,11 +3,13 @@ title: System built-ins
description: >
When a built-in value is not expressible in Flux, its value may be defined by the hosting environment.
All such values must have a corresponding builtin statement to declare the existence and type of the built-in value.
aliases:
- /v2.0/reference/flux/language/built-ins/system-built-ins/
menu:
v2_0_ref:
name: System built-ins
parent: Built-ins
weight: 301
parent: Flux specification
weight: 206
---
When a built-in value is not expressible in Flux, its value may be defined by the hosting environment.