4 ms·
You have to admire the person who designed the flexibility to have 87239 seconds not be old enough, but 87240 to be fine.
by x0x0 7mo ago
You have to admire the person who designed the flexibility to have 87239 seconds not be old enough, but 87240 to be fine.
- raverbashing 7mo agoThis is the difference between thinking about the user experience and thinking just about the technical aspect
- zelphirkalt 7mo agoI actually think it is not too bad a design, because seconds are the SI base unit for time. Putting something like "x days" requires additional parsing steps and therefore complexity in the implementation. Either knowing or calculating how many seconds there are in a day can be expected of anyone touching a project or configuration at this level of detail.
- wongarsu 7mo agoSeconds are also unambiguous. Depending on your chosen definition, "X days" may or may not be influenced by leap seconds and DST changes. I doubt anyone cares about an hour more or less in this context. But if you want multiple implementations to agree talking about seconds on a monotonic timer is a lot simpler
- sverhagen 7mo agoI came here to argue the opposite. Expressing it in seconds takes away questions about time zones and DST. I think you're incorrect to say that second are also ambiguous. Maybe what you mean is that days are more practical, but that seems very much a personal preference.
- BigTTYGothGF 7mo ago[flagged]
- pavel_lishin 7mo agoI think you misread the comment you're replying to.
- friendzis 7mo agoI understand the [flawed] reasoning behind "x seconds from now is going to be roughly now() + x on this particular system", but how does defining the cooldown from an external timestamp save you from dealing with DST and other time shenanigans? In the end you are comparing two timestamps and that comparison is erroneous without considering time shenanigans
- woodruffw 7mo agoCould you explain what you mean re: ambiguity? I understand why “calendar units” like months are ambiguous, but minutes, hours, days, and weeks all have fixed durations (which is why APIs like Python’s `timedelta` allows them).
- jon-wood 7mo agoIn the UK last Sunday was 23 hours long because we switched to BST, and occasionally leap seconds will result in a minute being something other 60 seconds.
- extraduder_ire 7mo agoNo it wasn't. The country instantaneously changed timezones from UTC+0 to UTC+1 (called something else locally), it was no different to any other timezone change from e.g. physically moving into another timezone.
- nightpool 7mo agoThe minute between December 31, 2016 23:59 and January 1st 2017 is 61 seconds, not 60 seconds. The hour that contains that minute is 3601 seconds, the day that contains that hour is 43201 seconds, etc. If you assume a fixed duration and simply multiply by 43200, your math will be wrong compared to the rest of the world. Daylight savings time makes a day take 23 hours or 25 hours. That makes a week take 7254000 seconds or 7261200 seconds. Etc.
- woodruffw 7mo agoThat’s what I mean by calendar units. These aren’t issues if you don’t try to apply durations to the “real” calendar. (This is all in the context of cooldowns, where I’m not convinced the there’s any real ambiguity risk by allowing the user to specify a duration in day or hour units rather than seconds. In that context a day is exactly 24 hours, regardless of what your local savings time rules are.)
- 7mo ago
- myhf 7mo agoexploiting the ambiguity in date formats by releasing a package during a leap second
- rolux 7mo ago> seconds are the SI base unit for time True. But seconds are not the base unit for package compromises coming to light. The appropriate unit for that is almost certainly days.
- PunchyHamster 7mo agothat kind of complexity is always worth it. Every single time. It's user time that you're saving and it also makes config clearer for readers and cuts out on "too many/little zeroes on accident" errors It's just library for handling time that 98% of the time your app will be using for something else.
- x0x0 7mo agoI find it best when I need a calculator to understand security settings. 604800 here we come
- dspillett 7mo agoProbably went with the simplest implementation, if starting from the current “seconds since epoch” value. Let the user do any calculations needed to translate three days into that measurement. It also efficiently annoys the most people at once: those what want hours will complain if they set it to days, thought that want days will complain if hours are used. By using minutes or seconds you can wind up both segments while not offend those who rightly don't care because they can cope with a little arithmetic :) Though doing what sleep(1) does would be my preference: default to seconds but allow m/h/d to be added to change that.
- Xirdus 7mo agoI'm old enough to remember computers being pitched as devices that can do tedious math for us. Now we have to do tedious math for them apparently.
- dspillett 7mo agoHence the way I would do it (and have for other purposes), as stated in my final sentence. Have the human state the intent and convert to your own internally preferred units as needed.
- darepublic 7mo agoI'm sure you would like to memorize all kinds of API instead of having something idiot proof and straightforward
- Xirdus 7mo agoAs if `minimumReleaseAge` in `[install]` section of `.bunfig.toml` doesn't require the same kind of memorization.
- moralestapia 7mo agoHey that's a great joke, you made me spill my morning home-brewed kombucha. I'm going to steal that one for my JavaScript monthly developers meetup. Is it ok if I attribute it to "Xirdus on Hacker News"?
- scoutt 7mo agoWell, you have 1000000 microseconds in between. That's a big threshold.