Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed3.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.114 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.77; '*S*': 0.00; 'matches': 0.07; 'string': 0.09; 'suggest': 0.14; 'from:addr:pobox.com': 0.16; 'from:addr:skip': 0.16; 'negative,': 0.16; 'str()': 0.16; 'suggested,': 0.16; 'sender:addr:gmail.com': 0.17; 'skip': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'patch': 0.29; 'message-id:@mail.gmail.com': 0.30; 'cases': 0.33; 'moment': 0.34; 'subject: (': 0.35; 'common': 0.35; 'objects': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'are,': 0.36; 'leads': 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'negative': 0.60; 'free': 0.61; 'took': 0.61; 'results': 0.69; '(5)': 0.74; 'unusual': 0.74; 'day': 0.76; 'behavior': 0.77; 'examples.': 0.84; 'skip:] 20': 0.84 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:content-type; bh=Fm8UzO9L6I2roOky4xeoRFBsx7lnfLoXbL2nnPxMwg4=; b=GQsGQzCeu2uSJ1YrewghL1/7/MKq5niBkDHI8EUdMxIEBB7S4C103ksAozhaeT7RRk vBJw79PpLFe+EY/ykg4hrcXDRM8IoIjHvjM2cxXdVri9IzwY1LhHJh/GAImjK4TIHcBN o3GylIkHuccY4sD7ECun8WdoPhc0AYp6Jh6ZDiniLJvYEsCbxyOBbEqwCk7Njj3Rn/9Y FXiryU7TPCGjhP3jREX3bip8T6quJMffchcZ1X6e3Ydl8vme8qzDd71zxAM2xx5QdQW0 GGyLE98G18kqB0xXlXms5USEXnBJGNTKDJvLsd1D5rTSHkoUyF3hyvPa8kmUrXmFA/z3 Vaqg== MIME-Version: 1.0 X-Received: by 10.50.79.194 with SMTP id l2mr30570084igx.8.1395921394350; Thu, 27 Mar 2014 04:56:34 -0700 (PDT) Sender: skip.montanaro@gmail.com In-Reply-To: References: <53336df8$0$29994$c3e8da3$5496439d@news.astraweb.com> Date: Thu, 27 Mar 2014 06:56:34 -0500 X-Google-Sender-Auth: UTANZcRBKLU86kh9Bt6-p3Sy07I Subject: Re: YADTR (Yet Another DateTime Rant) From: Skip Montanaro To: Python Content-Type: text/plain; charset=UTF-8 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395921402 news.xs4all.nl 2919 [2001:888:2000:d::a6]:35084 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69186 I took a moment to scan the datetime documentation. The behavior of str() on timedelta objects is very consistent, and matches the internal representation. From the docs: str(t) Returns a string in the form [D day[s], ][H]H:MM:SS[.UUUUUU], where D is negative for negative t. (5) Note (5) reads: String representations of timedelta objects are normalized similarly to their internal representation. This leads to somewhat unusual results for negative timedeltas. Feel free to submit a patch to improve str(t), where t is negative, though as Chris suggested, hashing this out on python-ideas would be a good idea. I suggest you start with some concrete examples. There are, as I see it, two common cases where t is negative: -1 day < t < 0 and t <= -1 day Skip