-
Notifications
You must be signed in to change notification settings - Fork 159
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
For brevity of LDT=>epochXxx, should LocalDateTime expose convenience properties from Absolute? #932
Comments
Since LocalDateTime encapsulates an Absolute, it seems reasonable for all of Absolute's methods/getters to be present on it. |
I agree that whichever form we decide in #750 should be added to LocalDateTime as well. |
I'll dissent here. I have seen way too many cases where people think that timestamps based on the Unix epoch should somehow be localized, rather than based on UTC. For example, in Moment.js: const m = moment();
console.log(+m);
console.log(+m.utc());
console.log(+m.tz('Asia/Tokyo')); Those will all output the exact same timestamp, but I've seen too many examples where people expect them to be different. Sometimes they'll even do a In other words: const ldt1 = Temporal.now.localDateTime('America/New_York');
const ldt2 = Temporal.now.localDateTime('Asia/Tokyo');
ldt1.epochMilliseconds === ldt2.epochMilliseconds //=> true, but may be surprising to some
ldt1.toAbsolute().epochMilliseconds === ldt2.toAbsolute().epochMilliseconds //=> true, and is not surprising |
Hi @mj1856 - what do you think makes the first case surprising but the second one unsurprising? They seem very similar. Also BTW, you might want to update your code to use |
Meeting 2020-10-09: Tentative consensus is to add these properties to ZonedDateTime:
@mj1856 - feel free to follow up if you disagree with doing this change. |
If this is already included in the ZDT draft? Can we close this one and use the main ZDT issue to track it? |
It is. Let's close it. |
LocalDateTime currently exposes a superset of DateTime's API. But logically it also encapsulates an Absolute too. Should it expose
epochSeconds
,epochMilliseconds
,epochMicroseconds
,epochNanoseconds
convenience properties?The specific reason would be to address brevity for the common use case where a user has an LDT and wants get a seconds or msecs since epoch. Operations involving epoch and/or legacy Date seem to be the most common brevity complaint that we've heard, so streamlining these use cases may make sense.
Related: #750.
The text was updated successfully, but these errors were encountered: