-
Notifications
You must be signed in to change notification settings - Fork 156
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
doc: converting LocalDateTime instance to ZonedDateTime #1
Comments
Haven't decided, but the following mirrors Java 8 mostly and I think it works well: var ldt = new temporal.LocalDateTime(2017, 12, 31, 23, 59);
var zoned = temporal.ZonedDateTime.of(ldt, 'America/Chicago', {
resolver: (mapping) => ({
skipped: mapping.forwardShifted(),
ambiguous: mapping.firstOccurrence()
})
}); //the options object with the resolver is optional here
var backToLocal = zoned.toLocalDateTime(); Java 8 has three methods for converting from local to zoned - I'm not sure if I want to get that deep. To me the resolver seems reasonable enough for control of ambiguous times. Use of the 'throws' mapping would create all the same functionality of the three method system, but allow it all in one. |
I like the var ldt = new temporal.LocalDateTime(2017, 12, 31, 23, 59);
var zoned = ldt.withZone('America/Chicago', {
resolver: (mapping) => ({
skipped: mapping.forwardShifted(),
ambiguous: mapping.firstOccurrence()
})
}); I like the parallel of using |
@timrwood both could probably quite reasonably be implemented. They both exist in Java. Will have to think how many options we want to give people. |
With the revised proposal, the types are now called let dt = temporal.createDateTime(2017, 12, 31, 23, 59);
let zi = dt.withZone('America/Chicago', options);
|
What is the API for converting between the two base types?
The text was updated successfully, but these errors were encountered: