Skip to content
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

non-utc datetime-arithmetic is out-of-scope in javascript? #142

Closed
kaizhu256 opened this issue Jul 10, 2019 · 12 comments
Closed

non-utc datetime-arithmetic is out-of-scope in javascript? #142

kaizhu256 opened this issue Jul 10, 2019 · 12 comments

Comments

@kaizhu256
Copy link
Contributor

in most software-integration scenarios i've encountered, javascript datetime-arithmetic is done exclusively in utc-reference to maintain consistency with parallel calculations done by databases, shell-scripts, and other external-systems i have to interact with.

note that this is different/distinct from date-only arithmetic.

@ljharb
Copy link
Member

ljharb commented Jul 10, 2019

I’m not sure what the point of this issue is - could you elaborate?

Note that i have encountered non-UTC date arithmetic frequently - see https://github.com/airbnb/react-dates which does it specifically for UI all the time - so this capability is incredibly critical for UI development in particular.

@kaizhu256
Copy link
Contributor Author

that library/example is for date-only arithmetic, which is distinct from datetime-arithmetic.

if additionally, the ui employed a time-picker, its preferable to transform the datetime to utc-reference so that both javascript and non-javascript systems on the backend can perform datetime-arithmetic consistently.

@ljharb
Copy link
Member

ljharb commented Jul 10, 2019

I don't agree that's preferable, nor that that's the way it's commonly done.

@kaizhu256 kaizhu256 changed the title non-utc datetime-arithmetic is over-scoped in javascript? non-utc datetime-arithmetic is out-of-scope in javascript? Jul 10, 2019
@kaizhu256
Copy link
Contributor Author

adding anecdotal datatpoint. at my current employ (a .net/c# shop), datetime-values are always converted to utc-reference when ingested into our system. this has also been the case with past 2 jobs.

so baton-passing/ingesting non-utc datetime is uncommon in my experience.

date-only values (e.g. "2019-10-07") are a separate issue.

@domenic
Copy link
Member

domenic commented Jul 10, 2019

If we're sharing anecdata, at Google we have separate types for local date-times (what this proposal calls "civil") and for instants (i.e. UTC times). We use them pervasively. Converting to UTC for non-instants would not pass code review.

@kaizhu256
Copy link
Contributor Author

thx for anecdata. curious, but is non-utc datetime-arithmetic (not date-arithmetic) pervasively used as well?

@sffc
Copy link
Collaborator

sffc commented Jul 10, 2019

Regarding what Google does in C++, feedback from the Google library authors is here: #139

@jorroll
Copy link

jorroll commented Jul 10, 2019

To bring back @ljharb's comment

I’m not sure what the point of this issue is - could you elaborate?

I'm still not sure what the point of this discussion is. @kaizhu256 are you trying to suggest that this proposal is not needed? That a subset of this proposal is not needed? Something else?

@kaizhu256
Copy link
Contributor Author

is non-utc datetime-arithmetic useful or an anti-pattern in javascript's problem-space? i'm thinking it might be an anti-pattern -- if you want to do datetime-arithmetic, it should be in utc-reference only.

@domenic
Copy link
Member

domenic commented Jul 10, 2019

Yes, it's quite useful. For example, consider "OK Google, remind me tomorrow at this time to water the plants", said at 4pm. You don't want that to be converted to UTC, add 1 day, and convert back to local time. That could give results off by one hour, because my local time zone experiences daylight savings time, whereas UTC does not. You need local-time-aware date arithmetic to handle cases like this.

@jorroll
Copy link

jorroll commented Jul 10, 2019

More generally, most website's / app's do not need to worry about multiple timezones. They will only ever be used in "local" time. I would argue that letting someone manipulate local time is important from an accessibility standpoint, where here accessibility means "inexperienced developer".

@ryzokuken
Copy link
Member

Closing this since the conversation seems to have reached consensus. Feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants