Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.031 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'say,': 0.05; 'python': 0.09; 'counting': 0.09; 'oh,': 0.09; 'spec': 0.09; 'ignore': 0.13; '(the': 0.15; '(like': 0.15; 'dec': 0.15; 'egg': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'longer.': 0.16; 'occurs).': 0.16; 'optionally': 0.16; 'progressive': 0.16; 'seconds,': 0.16; 'subject:values': 0.16; 'utc': 0.16; 'varies': 0.16; 'well-known': 0.16; 'wrote:': 0.17; 'thu,': 0.17; '(or': 0.18; 'translate': 0.20; 'received:209.85.216.46': 0.21; 'constant': 0.22; 'parse': 0.22; 'second': 0.24; 'allows': 0.25; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'change,': 0.27; 'replace': 0.27; 'message- id:@mail.gmail.com': 0.27; 'chris': 0.28; '"in': 0.29; "d'aprano": 0.29; 'steven': 0.29; 'yes.': 0.29; 'definition': 0.29; "i'm": 0.29; "we're": 0.30; 'fri,': 0.30; 'waste': 0.30; 'seconds': 0.30; 'year,': 0.30; 'largely': 0.33; 'to:addr:python-list': 0.33; 'likely': 0.33; 'received:google.com': 0.34; 'subject:?': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'should': 0.36; 'does': 0.37; 'being': 0.37; 'rather': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'positive': 0.38; 'mean': 0.38; 'some': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'your': 0.60; 'days': 0.60; 'day,': 0.60; 'most': 0.61; 'real': 0.61; 'free': 0.61; 'is.': 0.62; 'needing': 0.62; 'close': 0.63; 'day.': 0.63; 'worth': 0.63; 'ever': 0.63; 'times': 0.63; 'more': 0.63; 'jul': 0.65; 'surprise': 0.65; 'due': 0.66; 'believe': 0.69; 'increase': 0.72; 'day': 0.73; '1970,': 0.84; 'divide': 0.84; 'easter': 0.84; 'solar': 0.84; "they'd": 0.84; 'imagine': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=BPzqTlM/ov4VkDgkuwa8TOP+u4uXVmRPCQyV4Kjnrtc=; b=lBl/gHLgj+69UeJHvHeFr+uLdMvfQP0gjY3XHXqZfyVsrP6NjY93PC8IqXW063nJ1d ug036fw/ooP2zrEbY0dd4fYGlKzwm2KHK+aHufQ2mBUn9z/C4TU5zX4sY5qOqjBi0cPM FRfxRt+B5MVl0UWdZROtleGtRkJKDgr/+jNCnuvDUBxbFxy3ywXT1mvfUWLK2oYoIWVc +AGzMkEL6+53V/eWoMC+dIMG4LYqVCnO5C5b4AhQXDSGcN6S3RzoqBFE6E8TAtcN77/o DLryxq7bRYSOEt8D93Bw5LKuYJKOK4SCBSWFcToqy0mPVFRSug9DrRROKN6I+lr9/MQF /7Rw== MIME-Version: 1.0 In-Reply-To: <4ff5b086$0$29988$c3e8da3$5496439d@news.astraweb.com> References: <4ff5b086$0$29988$c3e8da3$5496439d@news.astraweb.com> Date: Fri, 6 Jul 2012 01:53:19 +1000 Subject: Re: simpler increment of time values? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 51 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1341503602 news.xs4all.nl 6947 [2001:888:2000:d::a6]:48079 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:24931 On Fri, Jul 6, 2012 at 1:19 AM, Steven D'Aprano 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