-
Notifications
You must be signed in to change notification settings - Fork 1
Convert Instant/ZonedDateTime -> Date #31
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
Comments
Thanks for this suggestion. I'd be concerned about For developers who think For this reason, if we do extend |
I agree with your assertion that many developers assume that However:
That said, most of the value is achieved by having |
Add
Date.fromTemporalInstant
andDate.fromTemporalZonedDateTime
function to easily create Dates from Temporal values.Advantages:
Converting to Date currently requires:
This is awkward, and requires remembering the unit for Dates. (seconds? millis? nanos?) For adoption, it's important that converting to/from Dates is easy and rebost.
This proposal offers convenience functions:
Concerns:
See:
Converting from ZonedDateTime and Date suggests that Date has time zone (not just offset)
Downcasting is common. No one would think that ZonedDateTIme -> Instant suggests that Instant has time zone.
Usage of Date should be discouraged
This sentiment vastly underestimates the stickiness of current Date usage and the necessity of easy conversion between the two.
new Date(instant.epochMilliseconds) is easy enough
With all due respect, not at all. For example MDN list the following constructor calls for Date:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date
I'm supposed to know that I should pass one arg, and that arg is milliseconds? Come on, man.
Prior art:
N/A
Constraints / corner cases:
N/A
The text was updated successfully, but these errors were encountered: