Skip to content

Update date documentation #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 83 additions & 2 deletions src/stdlib/date.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: Represents timestamps.

Represents timestamps.

The Date API is still preliminary and requires importing the `Date` object from the host \(as `Date`\).
The Date API is still preliminary with only a subset of properties and methods implemented. Note that getting the current date, via `Date.now`, requires importing the `Date` object from the host \(as `Date`\).

## Constructor

Expand All @@ -20,7 +20,7 @@ The Date API is still preliminary and requires importing the `Date` object from
* ```ts
function now(): i64
```
Returns the current UTC timestamp in milliseconds.
Returns the current UTC timestamp in milliseconds. To use this function you must import the `Date` object from the host \(as `Date`\).

* ```ts
function UTC(
Expand All @@ -34,6 +34,11 @@ The Date API is still preliminary and requires importing the `Date` object from
): i64
```
Returns the UTC timestamp in milliseconds of the specified date.

* ```ts
function fromString(dateTimeString: string): Date
```
Creates a Date object from an ISO 8601 formatted string.

## Instance members

Expand All @@ -46,3 +51,79 @@ The Date API is still preliminary and requires importing the `Date` object from
function setTime(value: i64): i64
```
Sets the UTC timestamp of this date in milliseconds and returns the timestamp.

* ```ts
function getUTCFullYear(): i32
```
Gets the full year according to universal time.

* ```ts
function setUTCFullYear(value: i32): i32
```
Sets the full year according to universal time.

* ```ts
function getUTCMonth(): i32
```
Gets the (zero indexed) month according to universal time.

* ```ts
function setUTCMonth(value: i32): i32
```
Sets the (zero indexed) month according to universal time.

* ```ts
function getUTCDate(): i32
```
Gets the day of the month according to universal time.

* ```ts
function setUTCDate(value: i32): i32
```
Sets the day of the month according to universal time.

* ```ts
function getUTCHours(): i32
```
Gets the hour according to universal time.

* ```ts
function setUTCHours(value: i32): i32
```
Sets the hour according to universal time.

* ```ts
function getUTCMinutes(): i32
```
Gets the minute according to universal time.

* ```ts
function setUTCMinutes(value: i32): i32
```
Sets the minute according to universal time.

* ```ts
function getUTCSeconds(): i32
```
Gets the second according to universal time.

* ```ts
function setUTCSeconds(value: i32): i32
```
Sets the second according to universal time.

* ```ts
function getUTCMilliseconds(): i32
```
Gets the millisecond according to universal time.

* ```ts
function setUTCMilliseconds(value: i32): i32
```
Sets the millisecond according to universal time.

* ```ts
function toISOString(): string
```
Returns the a string in simplified extended ISO 8601 format.