Re:JavaScript's “new Date()” causing 90% of Alibaba's intern...
by projct on Wednesday February 10, 2016 @04:23PM
(#11076100)
time is a giant disaster in every language and environment I've ever encountered :P
[ Parent
| on HN ]
Re:JavaScript's “new Date()” causing 90% of Alibaba's intern...
by mikehollinger on Wednesday February 10, 2016 @05:58PM
(#11076876)
https://www.youtube.com/watch?v=-5wpm-gesOY is a pretty entertaining video that talks about the various hoops developers must jump through.
Re:JavaScript's “new Date()” causing 90% of Alibaba's intern...
by com2kid on Thursday February 11, 2016 @02:10AM
(#11078665)
I work in embedded.
We have to do this on our own.
It is every bit as painful as it is made out to be.
A common problem that I don't see discussed much is the difference between recording when a time took place (just record and store it in UTC!) and then translating that into what the user expects to see. This is especially hard if you have information that should be grouped into "days", and a use case where the user changes time zones but may expect the same "relative to originally recorded time" to be shown when viewing past events.
A nightmare case.
Re:JavaScript's “new Date()” causing 90% of Alibaba's intern...
by douche on Wednesday February 10, 2016 @06:05PM
(#11076942)
If you haven't seen this, you should. Quite possibly my favorite youtube video, and this channel has a number of other great clips.
Re:JavaScript's “new Date()” causing 90% of Alibaba's intern...
by draw_down on Wednesday February 10, 2016 @04:25PM
(#11076129)
Yes. But front-end JS takes it to the next level by, for example, not providing any sane way to get the current locale.
Re:JavaScript's “new Date()” causing 90% of Alibaba's intern...
by xlm1717 on Wednesday February 10, 2016 @04:59PM
(#11076413)
Just don't do it on the front-end. Never do it on the front-end.
Re:JavaScript's “new Date()” causing 90% of Alibaba's intern...
by draw_down on Wednesday February 10, 2016 @05:47PM
(#11076785)
You have to. User specifies thing should happen at 2PM, their time, then POSTs that data to your API or whatever. Well, what time are they actually talking about? You need to know.
Re:JavaScript's “new Date()” causing 90% of Alibaba's intern...
by toomuchtodo on Wednesday February 10, 2016 @08:03PM
(#11077531)
You ask the user what time zone they're in? Better to have accurate data then guess.
Re:JavaScript's “new Date()” causing 90% of Alibaba's intern...
by redrummr on Thursday February 11, 2016 @02:19AM
(#11078696)
Especially considering this is consistent with not identifying the device beyond headers sent etc. and you can't just use an IP address to map the timezone as it may be shared at the tower/exchange kilometres away (DSL) or hundreds of kilometres away (wireless/cell) and cross timezones.
The best strategy is to suggest the [timezone|local shop|city name|whatever] and prompt for confirmation.
Re:JavaScript's “new Date()” causing 90% of Alibaba's intern...
by douche on Wednesday February 10, 2016 @05:42PM
(#11076750)
Moment.js is a must-have.
Re:JavaScript's “new Date()” causing 90% of Alibaba's intern...
by nstr007 on Wednesday February 10, 2016 @06:11PM
(#11076976)
If only we didn't need to add so much to our payload just to handle dates.
Re:JavaScript's “new Date()” causing 90% of Alibaba's intern...
by ErikAugust on Wednesday February 10, 2016 @10:06PM
(#11077982)
getTimezoneOffset()