Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65033

Re: Another surprise from the datetime module

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '(at': 0.04; 'meantime,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:module': 0.09; 'python': 0.11; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'seconds.': 0.16; 'wrote:': 0.18; 'print': 0.22; 'header:User-Agent:1': 0.23; 'least': 0.26; 'header:X-Complaints-To:1': 0.27; "doesn't": 0.30; 'subject:the': 0.34; 'subject:from': 0.34; 'there': 0.35; 'method': 0.36; 'charset:us-ascii': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'most': 0.60; 'smith': 0.68; 'discover': 0.82; "shouldn't,": 0.84; 'wanting': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Neil Cerutti <neilc@norwich.edu>
Subject Re: Another surprise from the datetime module
Date Thu, 30 Jan 2014 18:36:34 +0000 (UTC)
Organization Norwich University
References <lce2bf$4fo$1@panix2.panix.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host jackman.norwich.edu
User-Agent slrn/0.9.9p1/mm/ao (Win32)
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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>
Newsgroups comp.lang.python
Message-ID <mailman.6155.1391107018.18130.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391107018 news.xs4all.nl 2941 [2001:888:2000:d::a6]:38554
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65033

Show key headers only | View raw


On 2014-01-30, Roy Smith <roy@panix.com> wrote:
> I was astounded just now to discover that datetime.timedelta
> doesn't have a replace() method (at least not in Python 2.7).
> Is there some fundamental reason why it shouldn't, or is this
> just an oversight?
>
> My immediate use case was wanting to print a timedelta without
> the fractions of seconds.  The most straight-forward is:
>
> print td.replace(microseconds=0)

That would be nice.

In the meantime, this works for your use case:

td -= td % timedelta(seconds=1)

-- 
Neil Cerutti

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Another surprise from the datetime module roy@panix.com (Roy Smith) - 2014-01-30 12:32 -0500
  Re: Another surprise from the datetime module Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-30 18:03 +0000
  Re: Another surprise from the datetime module Neil Cerutti <neilc@norwich.edu> - 2014-01-30 18:36 +0000

csiph-web