-
Notifications
You must be signed in to change notification settings - Fork 22.7k
Reference for stage 3 temporal #37344
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
Changes from 37 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
27a3784
Reference for stage 3 temporal
Josh-Cena a477fa3
More description
Josh-Cena 9f50952
Duration docs
Josh-Cena bd0796c
Fix link
Josh-Cena fbd0601
Complete Duration docs
Josh-Cena 6ab2afd
Instant docs
Josh-Cena ef79211
Now docs
Josh-Cena 02295b7
TZ and calendar docs
Josh-Cena 0936403
PlainDate docs
Josh-Cena 889b358
Change ISO format description
Josh-Cena 7ca2b31
ZonedDateTime-specific stuff docs
Josh-Cena 7d9cdfe
PlainMonthDay docs, copy date-related fields to PlainDateTime
Josh-Cena a0ab015
PlainYearMonth docs
Josh-Cena f4342cf
PlainTime docs
Josh-Cena 4974d24
Intl docs
Josh-Cena 0a172b6
PlainDateTime docs
Josh-Cena ac18c5f
ZonedDateTime docs, easy part
Josh-Cena ac298ef
ZonedDateTime docs... and that shall be all
Josh-Cena f385d12
Simplifications and fixes
Josh-Cena 49485c0
typo
Josh-Cena 2995aaa
Merge branch 'main' into temporal
Josh-Cena 1324f8d
Apply suggestions from code review
Josh-Cena 44f3f7b
ISO 8601 -> RFC 9557
Josh-Cena a27aa82
Clarify time zone ID input
Josh-Cena 1ad6603
Time zone ID is required
Josh-Cena f30c94e
Slight reorg
Josh-Cena 7a86d33
Apply suggestions from code review
Josh-Cena fc843e3
More feedback
Josh-Cena cb3ce38
More reviews
Josh-Cena 26c065c
Merge branch 'main' into temporal
fiji-flo 0b7b04d
Reviews
Josh-Cena ce86a53
Reviews, Temporal.Now
Josh-Cena e28fc82
Mention precision of Temporal.Now methods
Josh-Cena 6756d76
Reviews, landing pages
Josh-Cena fc28f6b
Apply suggestions from code review
Josh-Cena 2e7b76a
Time zone / calendar / time components
Josh-Cena 2ebbb0e
Reviews, other constructors
Josh-Cena 0f7231a
Reviews, other constructors, arithmetic, monthCode
Josh-Cena 627cdeb
Merge branch 'main' into temporal
Josh-Cena bf72961
Update index.md
Josh-Cena 0ca21c0
Update index.md
Josh-Cena 25e1bb1
Update index.md
Josh-Cena aa9c790
Merge branch 'main' into temporal
Josh-Cena 4b68919
Reviews, some (?) conversion methods
Josh-Cena 1a21ed6
Last group of reviews
Josh-Cena 3fd90b9
Mention toTemporalInstant RangeError
Josh-Cena File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
54 changes: 54 additions & 0 deletions
54
...s/en-us/web/javascript/reference/global_objects/date/totemporalinstant/index.md
Josh-Cena marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,54 @@ | ||
--- | ||
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`. | ||
|
||
## 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.