Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #109180
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Zachary Ware <zachary.ware+pylist@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Format a timedelta object |
| Date | Fri, 27 May 2016 11:34:36 -0500 |
| Lines | 24 |
| Sender | zachary.ware@gmail.com |
| Message-ID | <mailman.27.1464366899.2277.python-list@python.org> (permalink) |
| References | <574686cc$0$1584$c3e8da3$5496439d@news.astraweb.com> <CAKJDb-Ng+o-QQAwkr7VkEXTxYnMGQhxS7VdMs6nTLg8_0fwBLQ@mail.gmail.com> <mailman.0.1464240542.2277.python-list@python.org> <57487425$0$1597$c3e8da3$5496439d@news.astraweb.com> <CAKJDb-NAOgoOQ2RrVUVARwdnNKobVt-LFL+Xpfskm4NgUJSV2A@mail.gmail.com> |
| Reply-To | python-list@python.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de BkE99hX03BeVaqbvtoTV8w+8UUPMu7CbNPeBJcQfTeow== |
| Return-Path | <zachary.ware@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.065 |
| X-Spam-Evidence | '*H*': 0.87; '*S*': 0.00; 'thu,': 0.15; '2016': 0.16; 'forty': 0.16; 'mark,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'seconds.': 0.16; 'subject:object': 0.16; 'wrote:': 0.16; 'sender:addr:gmail.com': 0.18; '>>>': 0.20; 'issue.': 0.20; 'to:name:python-list@python.org': 0.20; 'hours,': 0.22; 'am,': 0.23; "haven't": 0.24; 'header:In-Reply-To:1': 0.24; 'supported': 0.27; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'object,': 0.27; 'looks': 0.29; 'that.': 0.30; "i'd": 0.31; 'checked': 0.31; 'guess': 0.31; 'certain': 0.31; 'option': 0.31; "d'aprano": 0.33; 'extract': 0.33; 'steven': 0.33; 'though.': 0.33; 'open': 0.33; "i'll": 0.33; 'received:google.com': 0.35; 'quite': 0.35; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'display': 0.37; 'method': 0.37; 'thanks': 0.37; 'missing': 0.37; 'received:209.85.213': 0.37; 'manual': 0.38; 'received:209': 0.38; 'format': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'leading': 0.61; 'skip:u 10': 0.61; 'header:Reply-To:1': 0.67; 'hour': 0.69; 'reply-to:no real name:2**0': 0.71; '26,': 0.72; 'hour,': 0.84; 'reply- to:addr:python.org': 0.84; 'ware': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:from:date :message-id:subject:to; bh=LxRrOvVi9JDBJAnyPm0vwsCU7UBxYcYbxUV7+QnmN8w=; b=kWy+Lm+z/sv4zqlMEWwcBzCLRPDtHjFEQokK3qS+iNutvdyEpdNyF05A2pTshp9mPk 3uc1sQx89WZkYNOIMc9kwVGs5+Dm9vGfNS+COkldb6bZUWpTN1SrTE7mwuEuT3eyG7nD ytaMbzLdggetHVPgEFplZOJZ658ihnmB6nv97+cH0+7MtUKU9aVuQ9+l34eklnkILpli Bt8PB61atqCigzl8Jmkz4bzGkbIYdcwQ+w29h2lvl03ARoxMA2VHWlfeMvC87/zYTgL5 rhjHXyQtehLLA4SQ1OaTyHHIlgF1wjaZ5DIvisS8q/VmyfXj5AWOwsbvKm7vY2JQ6DtH dLUw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:sender:in-reply-to :references:from:date:message-id:subject:to; bh=LxRrOvVi9JDBJAnyPm0vwsCU7UBxYcYbxUV7+QnmN8w=; b=HN0yuCvFCZyii0irBFLPLXw/H3lfxl5w7MAsx6K5JGlEEwCsFRKmxZT6W3nNezhbdJ 39DhuE0K/oMvsyz7NUEQw384/Ymc5kjt4m24ZpsoQKO+I1VDZsg/0BO8r7Ds6DhHbsjG lnHs5OQRHS3HLwzZTYA804PuwUVdGTIxp50zxydnCCEREl5cbCgLq1oeMPVR2vj3PNlU qu8t/5SaNluqGckSd2yjmYHQ2/Dn21DIifi8WBtw0tMkQOrdqxsztbRdiNj2NGwqzHjk J2/yb81JbiQt4q2/K3ZTEbkagT64JOSSV4X6YnRHglJtTsI6pumzS7lE+vDQ/Kc3P520 B4Dw== |
| X-Gm-Message-State | ALyK8tJFmf5QbfT1pmFHnSk4En2t/GZ6loOyLBx+9j8qmLhRJcc+uvUKMUQDZMNDmKMMHGvUH5kxWetOkKJecA== |
| X-Received | by 10.159.33.132 with SMTP id 4mr8849808uac.43.1464366896209; Fri, 27 May 2016 09:34:56 -0700 (PDT) |
| In-Reply-To | <57487425$0$1597$c3e8da3$5496439d@news.astraweb.com> |
| X-Google-Sender-Auth | Pctb2Rb_MdpU9LmfWkc-1GDV1hY |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <CAKJDb-NAOgoOQ2RrVUVARwdnNKobVt-LFL+Xpfskm4NgUJSV2A@mail.gmail.com> |
| X-Mailman-Original-References | <574686cc$0$1584$c3e8da3$5496439d@news.astraweb.com> <CAKJDb-Ng+o-QQAwkr7VkEXTxYnMGQhxS7VdMs6nTLg8_0fwBLQ@mail.gmail.com> <mailman.0.1464240542.2277.python-list@python.org> <57487425$0$1597$c3e8da3$5496439d@news.astraweb.com> |
| Xref | csiph.com comp.lang.python:109180 |
Show key headers only | View raw
On Fri, May 27, 2016 at 11:21 AM, Steven D'Aprano <steve@pearwood.info> wrote: > On Thu, 26 May 2016 03:28 pm, Zachary Ware wrote: >> On Thu, May 26, 2016 at 12:16 AM, Steven D'Aprano >> <steve+comp.lang.python@pearwood.info> wrote: >>> I have a timedelta object, and I want to display it in a nice >>> human-readable format like 03:45:17 for "three hours, forty five minutes, >>> 17 seconds". >> >> >>> str(timedelta(seconds=100)) >> '0:01:40' > > Thanks Zach. Unfortunately, the format is not quite how I want it, so I > guess I'll have to extract the H:M:S fields manually from the seconds. What's missing the mark, no leading 0 on the hour, or the extra 0 hour specification? Yes, unfortunately it looks like manual extraction is your only option for that. I'd support an RFE for a strftime-like __format__ method on timedelta that only supported certain %-codes, though. I haven't checked to see if there's already an open issue. -- Zach
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Format a timedelta object Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-05-26 15:16 +1000
Re: Format a timedelta object Zachary Ware <zachary.ware+pylist@gmail.com> - 2016-05-26 00:28 -0500
Re: Format a timedelta object Steven D'Aprano <steve@pearwood.info> - 2016-05-28 02:21 +1000
Re: Format a timedelta object Zachary Ware <zachary.ware+pylist@gmail.com> - 2016-05-27 11:34 -0500
Re: Format a timedelta object Pete Forman <petef4+usenet@gmail.com> - 2016-05-27 21:41 +0100
Re: Format a timedelta object Marko Rauhamaa <marko@pacujo.net> - 2016-05-26 08:43 +0300
csiph-web