Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.032 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'represents': 0.05; 'method.': 0.07; 'year?': 0.09; 'cc:addr:python-list': 0.11; 'suggest': 0.14; '(it': 0.16; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'notation': 0.16; 'objects.': 0.16; 'readable': 0.16; 'roy': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'obviously': 0.18; 'wed,': 0.18; 'work,': 0.20; 'cc:addr:python.org': 0.22; 'days,': 0.24; 'skip': 0.24; 'cc:2**0': 0.24; 'second': 0.26; 'post': 0.26; 'header:In-Reply- To:1': 0.27; 'point': 0.28; 'function': 0.29; 'appear': 0.29; 'am,': 0.29; 'generally': 0.29; 'patch': 0.29; 'tim': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'probably': 0.32; 'regular': 0.32; 'maybe': 0.34; 'subject: (': 0.35; 'display': 0.35; 'problem.': 0.35; 'case,': 0.35; 'form.': 0.35; 'no,': 0.35; 'objects': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'done': 0.36; 'doing': 0.36; 'useful': 0.36; 'positive': 0.37; 'represent': 0.38; 'explain': 0.39; 'though,': 0.39; 'users': 0.40; 'how': 0.40; 'days': 0.60; 'negative': 0.60; 'most': 0.60; 'course': 0.61; 'provide': 0.64; 'taking': 0.65; 'minutes': 0.67; 'mar': 0.68; '26,': 0.68; 'smith': 0.68; 'presented': 0.69; 'obvious': 0.74; 'business,': 0.83; 'hour,': 0.84; 'deal,': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=lkgf936hIjyZqJ9dHYFEHGLTOCABqmGHJKkRAf4Noms=; b=HI8nlaijtSw3uLERufL0jQYw66B719SR9J3duCqKsk+BDT3LbBVFVOUCRcqEG0mhDH l0UKjtQzyU3FaiGSxEC5acDu+EMlXlsBOTv4Ra7Pwk1qn3CE8BQTdI8V7BdxPNoVflVM SnParYwxEP7fSe7eGUk8ba7dbPrjn1vK65U+pDKM2bUIgZn9cE4CGnUy5SjnCLS3RiAk AIkjLqpZvVCDxUjyouss/lr9bnOHgiRMhRCbP08aCsxM3bDPUcUrm+GPxDV0Gotte2Mh QfbNqqMKsYBiMS/n+TJSkfirEhAJmHs22M75lH4Dk2dJPmGN1ma3X5OkEfHjWXvTiqEC W5cw== MIME-Version: 1.0 X-Received: by 10.43.58.19 with SMTP id wi19mr13232750icb.53.1395848391096; Wed, 26 Mar 2014 08:39:51 -0700 (PDT) Sender: skip.montanaro@gmail.com In-Reply-To: <1102ec6b-6205-40f4-bb7c-d40f9d13115b@googlegroups.com> References: <1102ec6b-6205-40f4-bb7c-d40f9d13115b@googlegroups.com> Date: Wed, 26 Mar 2014 10:39:50 -0500 X-Google-Sender-Auth: gj4P6fHbDmnqvYBYbbWY0RaZP9I Subject: Re: YADTR (Yet Another DateTime Rant) From: Skip Montanaro To: Roy Smith Content-Type: text/plain; charset=UTF-8 Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395848399 news.xs4all.nl 2871 [2001:888:2000:d::a6]:46085 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69132 On Wed, Mar 26, 2014 at 10:04 AM, Roy Smith wrote: > No, what you said was "negative four days, positive 3605 seconds". My apologies for not showing all my work, professor. I use datetime and timedelta objects all the time. I did the arithmetic to go from 3605 to one hour, five minutes in my head. The point of my post was that there is no obvious one best way to present negative timedeltas in a human readable form. In my usage it's not generally a big deal, as most of the time I want to display datetime objects. In your case, it's obviously a problem. If Tim thought that timedelta objects would be presented to users as a regular course of doing business, maybe he would have given them a strftime() method. I suggest you write a function to format it the way you want and be done with it. You might consider taking a crack at a strftime() (and strptime?) implementation for timedelta objects that uses the ISO 8601 notation and submit it as a patch for datetimemodule.c. Note though, that the ISO8601 representation isn't without its own flaws (which might explain why Tim avoided it BITD): * It doesn't appear to provide a way to represent fractions of a second (though perhaps all the fields can be fractional) * How many days are in a month or a year? (It has format codes for both. Writing a useful strptime is probably impossible.) * It has other ambiguities ("M" represents both months and minutes - what were they thinking?) Skip