3 ms·
Technically, you're not likely to to have to fix a DST bug at 3AM any day but Sunday.
by throwaway_12629 7mo ago
Technically, you're not likely to to have to fix a DST bug at 3AM any day but Sunday.
- usefulcat 7mo ago// call foo() one day from now: sleep(86400); foo();
- hdjrudni 7mo agoSorry, sleep returned a Promise and you didn't await it. You called foo() immediately.
- koakuma-chan 7mo agoWhat you want there is to stop saying "day" and instead say "24 hours." This way the code is correct and you don't need to deal with time weirdness.
- danbruc 7mo agoNo, because if I want something to happen everyday at 12 o'clock, I have to wait for one day, if I wait for 24 hours, I will be off by an hour for half of the year.
- loloquwowndueo 7mo agoOnly if you live in one of the brain dead countries that observe the dst anachronism.
- eureka7 7mo agook, but they still observe it and you still have to deal with it in your code. our personal convictions don't change that fact.
- koakuma-chan 7mo agoWhy do you want something to happen everyday at 12 o'clock specifically? If this is truly what you want, sure.
- danbruc 7mo agoLunch break reminder popup?
- mklepaczewski 7mo agoYou seem to assume that a day always has 24 hours. Common (but not only) non-24h day lengths are: - 23 hours - 25 hours - 24 hours 1 second - 23 hours 59 minutes 59 seconds You could assume that a day isn't exactly 24 hours, but it's close-ish to 24 hours. Nope, not even close. And that assumes that we can treat an hour as a precise measure of time (we can't). On some systems, even a second is not a precise measure of time (second smearing). To make things worse, those are "simple" edge cases. Time is hard. I'm not sure if I can make any statement about time that is true.
- koakuma-chan 7mo agoI am saying that you shouldn't use day as a unit of time. You should use second, minute, hour, etc, because these have a constant duration. sleep(86400) should reliably make your thread sleep for at least 24 hours.
- mklepaczewski 7mo agoIt depends on the context and the system you’re working with. In some systems, an hour may last 3599, 3600 or 3601 seconds (due to the leap second), a minute may be 59,60 or 61 seconds. Even a second is not always a „true” second. There’s no single time unit that works for all situations.
- dskloet 7mo agoThat's a great example of the kind of wrong assumption that makes dealing with dates and times so challenging. Some countries start on a Friday or Saturday and until 2022 Iran could start any day of the week although never at 3AM.
- manarth 7mo agoSome countries alter their observance of DST in line with their observance of Ramadan, which means that the time-offset changes aligned with Ramadan. Ramadan is observed from one visual sighting of a crescent moon to the next. Cloud conditions may prevent sighting and thereby alter the official start of Ramadan for an individual location, and from time-to-time, the start of a country's change in timezone.
- jacquesm 7mo agoCue a longish article titled 'Falsehoods Programmers Believe About Time'
- troad 7mo ago> Some countries alter their observance of DST in line with their observance of Ramadan, which means that the time-offset changes aligned with Ramadan. Only Morocco does this, I believe, and it's not even clear that that's actually official time at this point. In 2018, Morocco abolished DST, but it seems unclear what that means in practice. I'd love it if someone from Morocco could weigh in on what the actual situation is on the ground. Do people still change their clocks for Ramadan? Would they be annoyed if a website kept Moroccan users on standard time during Ramadan?