Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!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.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'classes.': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'wrapper': 0.09; '~ethan~': 0.09; 'python': 0.11; 'wrote': 0.14; 'computes': 0.16; 'pity': 0.16; 'pythonista,': 0.16; 'roy': 0.16; 'str()': 0.16; 'wrote:': 0.18; 'value.': 0.19; 'print': 0.22; 'header:User-Agent:1': 0.23; 'second': 0.26; 'header:In-Reply- To:1': 0.27; 'idea': 0.28; "i'm": 0.30; 'code': 0.31; 'supposed': 0.32; 'ago': 0.33; 'moment': 0.34; '"the': 0.34; 'subject: (': 0.35; 'in.': 0.36; 'like,': 0.36; 'module.': 0.36; 'set.': 0.36; 'useful': 0.36; 'charset:us-ascii': 0.36; 'being': 0.38; 'represent': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'previous': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'how': 0.40; 'received:173': 0.61; 'first': 0.61; 'hours': 0.66; 'periodically': 0.68; 'received:69.56': 0.68; 'roles': 0.68; 'smith': 0.68; 'default': 0.69; 'day': 0.76; 'imagine': 0.93 Date: Tue, 25 Mar 2014 18:19:30 -0700 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: YADTR (Yet Another DateTime Rant) References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3304.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source-IP: 173.12.184.233 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.233]) [173.12.184.233]:57939 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20= 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395796821 news.xs4all.nl 2892 [2001:888:2000:d::a6]:58978 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69091 On 03/25/2014 05:58 PM, Roy Smith wrote: > One of my roles on this newsgroup is to periodically whine about > stupidities in the Python datetime module. This is one of those times. > > I have some code which computes how long ago the sun set. Being a nice > pythonista, I'm using a timedelta to represent this value. It would be > difficult to imagine a less useful default way to print a timedelta: > > previous sunset: -1 day, 22:25:26.295993 > > The idea of str() is that it's supposed to return a human-friendly > representation of a value. Humans do not say things like, "The sun set > 1 day ago plus 22 hours and 25 minutes". I'm not sure whether to admire you for your stick-to-it-iveness, or pity you for the plight you are in. Either the first or second time I hit a datetime WTF moment I wrote my own wrapper classes. -- ~Ethan~