3 ms·
Seriously?! Man, dealing with time can just never be simple...
by openasocket 9y ago
Seriously?! Man, dealing with time can just never be simple...
- _jal 9y agoTime, to me, is the canonical example of "things that people think should be easy, aren't". It has everything - complex, constantly changing "business" rules, exceptions generated essentially randomly by a shadowy cabal[1] nobody's ever heard of, "impossible" situations like the 11 days that never happened and other technically arbitrary calendar edits[2], multiple silly base conversions, really weird rules for picking certain dates[3], lots of opportunities for making fencepost errors, and lots of other things. Which leads me to my rule with time programming: Never fail to use a solid library, unless you're unfortunate enough to be writing one. This[4] is a great, necessary but not sufficient book if you have to do that. [1] https://en.wikipedia.org/wiki/International_Earth_Rotation_and_Reference_Systems_Service https://en.wikipedia.org/wiki/International_Earth_Rotation_a... [2] For example, https://en.wikipedia.org/wiki/Swedish_calendar https://en.wikipedia.org/wiki/Swedish_calendar [3] https://en.wikipedia.org/wiki/Easter#Computations https://en.wikipedia.org/wiki/Easter#Computations [4] https://www.amazon.com/Calendrical-Calculations-Nachum-Dershowitz/dp/0521702380 https://www.amazon.com/Calendrical-Calculations-Nachum-Dersh...
- deepsun 9y agoDon't even mention how to calculate number of weeks in a year! It's often needed in real world programming for business reports, yet Joda-time library still doesn't support weeks not starting on Monday (like USA-ones) for that.