News for hackers. Stuff that matters.
Re:Dates and Times in JavaScript – A New API for Dates from ... by frenchyatwork on Thursday July 09, 2020 @02:09PM (#23783186)
Timestamps are damn trivial. When people use dates, that's all they want 90% of the time. The remaining 10% is where all the hard problems are.

For example, lets say I have a store that opens from 8:00-17:00 every day, and it's currently 22:00. How long is it till it opens next?

Re:Dates and Times in JavaScript – A New API for Dates from ... by noja on Thursday July 09, 2020 @02:14PM (#23783248)
Three days and an hour more than you think, because it's the weekend, and an extra day because the public holiday for tomorrow may or not be a working day. Oh and there was a timezone change.
Re:Dates and Times in JavaScript – A New API for Dates from ... by bonedangle on Thursday July 09, 2020 @02:44PM (#23783571)
And it's December 31st.. Still shocked by how many times I see a year rollover go bad.
Re:Dates and Times in JavaScript – A New API for Dates from ... by unilynx on Thursday July 09, 2020 @05:15PM (#23785314)
Even before the rollover it get's bad. I had a CI failure on 31 December 2018 for code which worked fine on 31 December 2017, because it was the first time for that code to have Dec 31 in week 1 of the next year.

And last year someone else's code failed on 30 December 2019, so I had a pretty good idea where to look.

Still need to fix a bug in code written only yesteryear because the 1st of July wasn't on a Monday this year, but I decided to snooze that test failure ... it'll work fine again in 9 years.

Re:Dates and Times in JavaScript – A New API for Dates from ... by aarong11 on Thursday July 09, 2020 @02:51PM (#23783668)
There was a leap second too, you forgot that one!
Re:Dates and Times in JavaScript – A New API for Dates from ... by timgilbert on Thursday July 09, 2020 @03:29PM (#23784075)
...oh, and I hope you know whether your customer is Israeli or Palestinian!

https://www.972mag.com/the-worlds-only-ethnic-time-zone/

Re:Dates and Times in JavaScript – A New API for Dates from ... by reggieband on Thursday July 09, 2020 @05:31PM (#23785462)
People joke, but I worked on a calendar application (well, it was a time series graph) where a leap second caused a rendering bug.
Re:Dates and Times in JavaScript – A New API for Dates from ... by yxhuvud on Thursday July 09, 2020 @05:47PM (#23785608)
There was this bug in Java related to a leap second that broke all Java servers in the world one summer..
Re:Dates and Times in JavaScript – A New API for Dates from ... by tigershark on Friday July 10, 2020 @03:14AM (#23788996)
No, they are not trivial at all as I explained in my previous comment. For more sauce: https://codeblog.jonskeet.uk/2019/03/27/storing-utc-is-not-a...

About your question it’s impossible to answer without further context. There may be DST tonight, or a leap second, or the enforcement of some strange treaty that will change the time zone..

Re:Dates and Times in JavaScript – A New API for Dates from ... by other_herbert on Thursday July 09, 2020 @05:40PM (#23785551)
This is a case for events! The store opens when the owner unlocks the door..... but since you are in that nebulous time when it is "closed" the next "open" may never happen.. so maybe what really needs to happen is a giant disclaimer around times for things...

like in your search results for let's say some M-F 8-5 business... it would say "Hours: 8:00-17:00, Closed right now, in 72% of the cases, the next opening time is tomorrow morning at 8"

Re:Dates and Times in JavaScript – A New API for Dates from ... by smichel17 on Thursday July 09, 2020 @10:58PM (#23787711)
As a shortcut for coming up with the corner cases yourselves, this document has a good list of them: https://moment.github.io/luxon/docs/manual/math.html
Re:Dates and Times in JavaScript – A New API for Dates from ... by jniedrauer on Thursday July 09, 2020 @09:40PM (#23787289)
I recently did this for a task scheduler. The logic lives in SQL. That was a "fun" query to write... You might think it's the wrong tool for the job, but it was a lot faster than reading every possible row and checking it in the application itself.
Re:Dates and Times in JavaScript – A New API for Dates from ... by mad182 on Thursday July 09, 2020 @02:41PM (#23783534)
You forgot there will be a leap second and switch to summer time.