-
Notifications
You must be signed in to change notification settings - Fork 22.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reference for stage 3 temporal (#37344)
* Reference for stage 3 temporal * More description * Duration docs * Fix link * Complete Duration docs * Instant docs * Now docs * TZ and calendar docs * PlainDate docs * Change ISO format description * ZonedDateTime-specific stuff docs * PlainMonthDay docs, copy date-related fields to PlainDateTime * PlainYearMonth docs * PlainTime docs * Intl docs * PlainDateTime docs * ZonedDateTime docs, easy part * ZonedDateTime docs... and that shall be all * Simplifications and fixes * typo * Apply suggestions from code review Co-authored-by: Justin Grant <[email protected]> * ISO 8601 -> RFC 9557 * Clarify time zone ID input * Time zone ID is required * Slight reorg * Apply suggestions from code review Co-authored-by: Chris Mills <[email protected]> * More feedback * More reviews * Reviews * Reviews, Temporal.Now * Mention precision of Temporal.Now methods * Reviews, landing pages * Apply suggestions from code review Co-authored-by: Eric A. Meyer <[email protected]> * Time zone / calendar / time components * Reviews, other constructors * Reviews, other constructors, arithmetic, monthCode * Update index.md * Update index.md * Update index.md * Reviews, some (?) conversion methods * Last group of reviews * Mention toTemporalInstant RangeError --------- Co-authored-by: Justin Grant <[email protected]> Co-authored-by: Chris Mills <[email protected]> Co-authored-by: Eric A. Meyer <[email protected]> Co-authored-by: Brian Smith <[email protected]>
- Loading branch information
1 parent
e5249d6
commit a4e9bce
Showing
282 changed files
with
17,552 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...s/en-us/web/javascript/reference/global_objects/date/totemporalinstant/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
title: Date.prototype.toTemporalInstant() | ||
slug: Web/JavaScript/Reference/Global_Objects/Date/toTemporalInstant | ||
page-type: javascript-instance-method | ||
browser-compat: javascript.builtins.Date.toTemporalInstant | ||
--- | ||
|
||
{{JSRef}} | ||
|
||
The **`toTemporalInstant()`** method of {{jsxref("Date")}} instances returns a new {{jsxref("Temporal.Instant")}} object with the same {{jsxref("Temporal/Instant/epochMilliseconds", "epochMilliseconds")}} value as this date's [timestamp](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#the_epoch_timestamps_and_invalid_date). | ||
|
||
Use this method to convert legacy `Date` values to the `Temporal` API, then further convert it to other {{jsxref("Temporal")}} classes as necessary. | ||
|
||
## Syntax | ||
|
||
```js-nolint | ||
toTemporalInstant() | ||
``` | ||
|
||
### Parameters | ||
|
||
None. | ||
|
||
### Return value | ||
|
||
A new {{jsxref("Temporal.Instant")}} object with the same {{jsxref("Temporal/Instant/epochMilliseconds", "epochMilliseconds")}} value as this date's timestamp. Its microsecond and nanosecond components are always `0`. | ||
|
||
### Exceptions | ||
|
||
- {{jsxref("RangeError")}} | ||
- : Thrown if the date is [invalid](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#the_epoch_timestamps_and_invalid_date) (it has a timestamp of `NaN`). | ||
|
||
## Examples | ||
|
||
### Using toTemporalInstant() | ||
|
||
```js | ||
const legacyDate = new Date("2021-07-01T12:34:56.789Z"); | ||
const instant = legacyDate.toTemporalInstant(); | ||
|
||
// Further convert it to other objects | ||
const zdt = instant.toZonedDateTimeISO("UTC"); | ||
const date = zdt.toPlainDate(); | ||
console.log(date.toString()); // 2021-07-01 | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## Browser compatibility | ||
|
||
{{Compat}} | ||
|
||
## See also | ||
|
||
- {{jsxref("Temporal.Instant")}} | ||
- {{jsxref("Temporal.ZonedDateTime")}} | ||
- {{jsxref("Temporal/Instant/fromEpochMilliseconds", "Temporal.Instant.fromEpochMilliseconds()")}} |
Oops, something went wrong.