Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #24931

Re: simpler increment of time values?

References <CAHzaPEO5D498zepGC0EVVURdUE7qxYJk6ksd5yS_Xj_hh5iiyQ@mail.gmail.com> <CAHzaPEMKGbUPhpfaB5bFkxJkMsmHrCzPZojYB7ZVO2r8P0MGAg@mail.gmail.com> <mailman.1823.1341496599.4697.python-list@python.org> <4ff5b086$0$29988$c3e8da3$5496439d@news.astraweb.com>
Date 2012-07-06 01:53 +1000
Subject Re: simpler increment of time values?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1835.1341503602.4697.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Jul 6, 2012 at 1:19 AM, Steven D'Aprano
<steve+comp.lang.python@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: simpler increment of time values? Chris Angelico <rosuav@gmail.com> - 2012-07-05 23:56 +1000
  Re: simpler increment of time values? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-05 15:19 +0000
    Re: simpler increment of time values? Rick Johnson <rantingrickjohnson@gmail.com> - 2012-07-05 08:39 -0700
      Re: simpler increment of time values? Chris Angelico <rosuav@gmail.com> - 2012-07-06 01:59 +1000
    Re: simpler increment of time values? Chris Angelico <rosuav@gmail.com> - 2012-07-06 01:53 +1000
    Re: simpler increment of time values? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-06 00:42 -0400

csiph-web