8 ms·
Oh yes. Any time I see code that tries to do some kind of scheduling, the first thing I ask is if they have considered using a library someone else has written
by Spoom 5y ago
Oh yes. Any time I see code that tries to do some kind of scheduling, the first thing I ask is if they have considered using a library someone else has written. Way too many things can subtly go wrong, but new folks tend to think it should be easy, because how hard can it be to work with dates?
- tentacleuno 5y ago> because how hard can it be to work with dates? Oh man, tell me about it. Timezones are the worst. No wonder so many people just give up and use Moment.js.
- dheera 5y agoUse UTC UNIX timestamps (i.e. Date.now()) for ALL time-related processing and only convert to hours/minutes when taking input/output from the user.
- aidos 5y agoUh oh, we’re going there again. If you’re doing anything in the future, that’s not always the correct thing to do. (Instants vs wall time etc)
- mypalmike 5y agoThat's a good starting point, and certainly good advice for marking current time and past times. But keep in mind that future event absolute UTC can change due to politics, e.g. a change in daylight savings rules, which is less rare than you might imagine (https://en.m.wikipedia.org/wiki/Daylight_saving_time_by_country#Past_observance https://en.m.wikipedia.org/wiki/Daylight_saving_time_by_coun...). That concert scheduled a year from now at 8pm in UTC+5 might actually end up occurring at 8pm in UTC+6.
- notreallyserio 5y ago> certainly good advice for marking current time and past times But not too far past!
- anchpop 5y agoHmm, I think you should use TAI over UTC because UTC has leap-second corrections, Which means that the current time + X seconds might not actually be X seconds from now
- misnome 5y agoBut I want my 4pm weekly meeting to always happen at 4pm, even if DST changes.
- dheera 5y agoIf DST changes and you live in a democracy, it's your fault. Vote against DST. If you don't get what you want unleash the wrath on your congress member, not the software.
- amalcon 5y agoI once had briefly traveled into a different time zone (so briefly that I hadn't thought about it) when I received a phone call asking to reschedule a doctor appointment. I entered the new time into my calendar. Then, I was an hour late to the appointment. My phone had adopted the timezone of the cell tower, and the calendar assumed I had meant "local time where I scheduled the appointment".
- jwandborg 5y agoI've been bit by bugs when coming to moment.js from other languages. It's the only datetime library I knew of, before you'll tell me about all the others, that mutates the datetime object when you do arithmetic.
- duxup 5y ago> because how hard can it be to work with dates? Man they are so hard that you could go on for hours about it. https://www.codingblocks.net/podcast/why-date-ing-is-hard/ https://www.codingblocks.net/podcast/why-date-ing-is-hard/
- munk-a 5y agoThere are seven time zones in Indiana in the tz database[1] - this doesn't count the two most used ones America/Chicago and America/New_York there's also a Kentucky tz that slightly spills into the state. Whenever anyone makes any comment about dates and times being easy to compute I just mention that yes, there are seven time zones in Indiana. Now the actual issues tend to arise when software makes assumptions like "every second will actually occur", "each second only happens once", "every minute has 60 seconds", "every day has 86400 seconds" amongst a plethora of other bad assumptions... but those are a lot more complicated to explain. I like leaning on Indiana. 1. https://en.wikipedia.org/wiki/Time_in_Indiana#tz_database https://en.wikipedia.org/wiki/Time_in_Indiana#tz_database
- VTimofeenko 5y agoA great collection of those "every minute has 60 seconds" assumptions and why they are incorrect: https://yourcalendricalfallacyis.com/ https://yourcalendricalfallacyis.com/
- hwc 5y agoI just want to specify International Atomic Time, relative to some universally-agreed-upon epoch, in nanosecond units.
- withinboredom 5y agoSo without leap seconds/days, how does one keep their clocks in sync with reality?
- etherealG 5y agoOne realises that one’s time is relative anyway and any universal time is just one’s own will to join a collective agreement that one doesn’t have to abide by. Then one puts this notion aside and prefers not to worry oneself with such things.
- withinboredom 5y ago