3 ms·
rolling your own time library is as crazy as rolling your own crypto
by cbxjksls 2y ago
rolling your own time library is as crazy as rolling your own crypto
- gruez 2y agoTo be fair most time libraries suck and can't handle fairly basic operations. For instance, if you're using python's datetime module and want to get the start/end dates of the current month, you need to "roll your own" like now = datetime.now() month_start = date(now.year, now.month, 1) month_end = date(now.year, now.month + 1, 1) - timedelta(days=1)
- Caligatio 2y agoYou should use: calendar.monthrange
- MadnessASAP 2y agoIf you're going to copy my code onto HN I would appreciate attribution. /s
- brianwawok 2y agoSo in Dec your code hits month 13? Kinda funny in a post how rolling your own time library is easy we made trivial bugs
- deleted 2y ago[deleted]
- gruez 2y agoThat's the point. I'm not advocating rolling your own date logic, only pointing out how easy it is to for "roll your own" logic to make its way into code even if if you're using a datetime library.
- ainiriand 2y agoYou probably haven`t used phps Carbon.
- orf 2y agoFirst result on google for “python's datetime module and want to get the start/end dates of the current month” shows a simple solution: https://stackoverflow.com/questions/42950/get-the-last-day-of-the-month https://stackoverflow.com/questions/42950/get-the-last-day-o...
- downrightmike 2y agoJust use unix time directly
- nitwit005 2y agoThe typical time libraries don't deal with satellites. Clocks are running at a slightly different rate in orbit.
- JPLeRouzic 2y ago“The root cause was identified as a software issue within the ground segment”
- nitwit005 2y agoYes, a thing that interacts with satellites, where you would expect that code to be.