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


Groups > comp.lang.python > #69148

Re: datetime

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.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.061
X-Spam-Evidence '*H*': 0.88; '*S*': 0.00; 'argument': 0.05; 'think,': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'finney': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'import': 0.22; 'header:User-Agent:1': 0.23; 'convenient': 0.24; 'people,': 0.24; 'defined': 0.27; 'header:X-Complaints-To:1': 0.27; 'writes:': 0.31; 'yesterday': 0.31; 'url:python': 0.33; 'skip:d 20': 0.34; 'there': 0.35; 'url:org': 0.36; 'should': 0.36; 'ben': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'even': 0.60; 'easy': 0.60; 'today,': 0.61; 'url:3': 0.61; 'today': 0.64; 'skip:\xe2 10': 0.65; '8bit%:43': 0.74; 'received:125': 0.84; 'sony': 0.84; 'victor': 0.84; 'tomorrow': 0.95
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ben Finney <ben+python@benfinney.id.au>
Subject Re: datetime
Date Thu, 27 Mar 2014 08:36:42 +1100
References <CABLWypNDCGcojSWR_Dp9NKJtEQH9cshgTZoY=7cm6Ye9_Ai73g@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host jigong.madmonks.org
X-Public-Key-ID 0xBD41714B
X-Public-Key-Fingerprint 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-gpg.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
Cancel-Lock sha1:hDqvwLAfYuyuy8xHx/9Zm74OrO4=
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.8591.1395869819.18130.python-list@python.org> (permalink)
Lines 23
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1395869819 news.xs4all.nl 2943 [2001:888:2000:d::a6]:50438
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:69148

Show key headers only | View raw


Victor Engle <victor.engle@gmail.com> writes:

> It would be convenient if datetime.date.today() accepted an argument
> as an offset from today, like datetime.date.today(-1). Is there an
> easy way to do this with datetime?

The types defined in ‘datetime’ can perform calendar arithmetic::

    import datetime

    today = datetime.date.today()
    one_day = datetime.timedelta(days=1)
    yesterday = today - one_day
    tomorrow = today + one_day

<URL:http://docs.python.org/3/library/datetime.html#datetime.timedelta>

-- 
 \        “Most people, I think, don't even know what a rootkit is, so |
  `\     why should they care about it?” —Thomas Hesse, Sony BMG, 2006 |
_o__)                                                                  |
Ben Finney

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


Thread

Re: datetime Ben Finney <ben+python@benfinney.id.au> - 2014-03-27 08:36 +1100

csiph-web