Skip to content

Commit

Permalink
Document time units. Fixes #1277
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Apr 4, 2016
1 parent 68e0c1a commit cdfbd64
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions site/docs/timeunit.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,26 @@ permalink: /docs/timeunit.html

`timeUnit` property of a channel definition sets the level of specificity for a temporal field. Currently supported values are:

- Non-periodic Time Unit: `'year'`, `'yearmonth'`, `'yearmonthday'`, `'yearmonthdate'`, `'yearday'`, `'yeardate'`, `'yearmonthdayhours'`, `'yearmonthdayhoursminutes'`.

- Non-periodic Time Unit: `'year'`, `'yearmonth'`, `'yearmonthday'`, `'yearmonthdate'`, `'yearday'`, `'yeardate'`, `'yearmonthdayhours'`, `'yearmonthdayhoursminutes'`.
- For example the `yearmonth` of `April 4, 2016 11:52:34` is `April 2016`.
- Periodic Time Unit: `'month'`, `'day'`, `'date'`, `'hours'`, `'minutes'`, `'seconds'`, `'milliseconds'`, `'hoursminutes'`, `'hoursminutesseconds'`, `'minutesseconds'`, `'secondsmilliseconds'`.


## Date/Time Units

Vega-Lite supports the following time units, which can be combined into the `timeUnit` properties above (e.g. `yearmonthday`, `hoursminutes`).

| Function | Description | Example time unit of `Monday April 4, 2016 11:52:34:0201` |
| :------------ | :------------- | :-----------------------------------------------|
| `date` | returns the day of the month for a given date input, in local time | `4` |
| `day` | return the day of the week for a given date input, in local time | `1` |
| `year` | returns the year for a given date input, in local time | `2016` |
| `month` | returns the (zero-based) month for a given date input, in local time | `3` |
| `hours` | returns the hours component for a given date input, in local time | `11` |
| `minutes` | returns the minutes component for a given date input, in local time | `52` |
| `seconds` | returns the seconds component for a given date input, in local time | `34` |
| `milliseconds`| returns the milliseconds component for a given date input, in local time | `0201` |

<!-- TODO: given a example datetime, show examples show each different time unit property transforms the original time -->

#### Example
Expand Down

0 comments on commit cdfbd64

Please sign in to comment.