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


Groups > comp.lang.python > #69148 > unrolled thread

Re: datetime

Started byBen Finney <ben+python@benfinney.id.au>
First post2014-03-27 08:36 +1100
Last post2014-03-27 08:36 +1100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#69148 — Re: datetime

FromBen Finney <ben+python@benfinney.id.au>
Date2014-03-27 08:36 +1100
SubjectRe: datetime
Message-ID<mailman.8591.1395869819.18130.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web