On Fri, Jul 6, 2012 at 1:19 AM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > On Thu, 05 Jul 2012 23:56:37 +1000, Chris Angelico wrote: > >> (The "magic number" 86400 is a well-known number, being seconds in a >> day. > > Does that include leap seconds?
No it doesn't, hence... >> Feel free to replace it with 24*60*60 if it makes you feel better; >> I'm pretty sure Python will translate it into a constant at parse time. >> Or alternatively, have a module-level constant SECONDS_IN_A_DAY = 86400, >> in case that number should ever change.) > > "In case"? ... this not being entirely tongue-in-cheek. I believe the UTC spec allows for a progressive increase in the number of leap seconds, from the current "maybe one a year" at either Dec or June to having them multiple months a year, to having a leap second optionally every day, to having one a day and multiple leap seconds on some days. But it's not until we're actually in that last state (or close to it) that I would consider changing SECONDS_IN_A_DAY to 86401. Leap seconds are largely outside the concept of "dateless time". > The number of seconds in a day (true solar day) varies ... > it is also systematically slowing due to tidal friction. > ... in a mere thousand years, the length of the > mean solar day will be about a second longer. Yes. It's rather more likely to be an issue than, say, "PI = 3.14159" needing to change, but you do still have to consider what your definition of time is. If you're actually counting real time-since-epoch, then you need to either include leap seconds in your count (like TAI does) or ignore them (like Unix time does - divide Unix time by 86400 and you get the number of days since 1970, but a second's worth of Unix times "happen twice" when a positive leap second occurs). However, I think it would only surprise people if: 23:30 + 03:45 = 03:14:59 and they'd think it was an easter egg for displaying one of a geek's favorite numbers. > Imagine how much extra work we'll be able to get done! Oh, I reckon most people will waste it on sleep... ChrisA -- http://mail.python.org/mailman/listinfo/python-list