Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46975
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!panix!gordon |
|---|---|
| From | John Gordon <gordon@panix.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: How to increment date by week? |
| Date | Tue, 4 Jun 2013 21:48:54 +0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Lines | 26 |
| Message-ID | <kolnc6$l1h$1@reader1.panix.com> (permalink) |
| References | <b07dac48-1479-42cc-908c-21a3b2e14198@googlegroups.com> |
| NNTP-Posting-Host | panix1.panix.com |
| X-Trace | reader1.panix.com 1370382534 21553 166.84.1.1 (4 Jun 2013 21:48:54 GMT) |
| X-Complaints-To | abuse@panix.com |
| NNTP-Posting-Date | Tue, 4 Jun 2013 21:48:54 +0000 (UTC) |
| User-Agent | nn/6.7.3 |
| Xref | csiph.com comp.lang.python:46975 |
Show key headers only | View raw
In <b07dac48-1479-42cc-908c-21a3b2e14198@googlegroups.com> PieGuy <r90230@gmail.com> writes:
> Starting on any day/date, I would like to create a one year list, by week (start date could be any day of week). Having a numerical week index in front of date, ie 1-52, would be a bonus.
> ie, 1. 6/4/2013
> 2. 6/11/2013
> 3. 6/18/2013....etc to # 52.
> And to save that result to a file.
> Moving from 2.7 to 3.3
> TIA
from datetime import date, timedelta
the_date = date(year=2013, month=6, day=4)
print "%d. %s" % (1, the_date)
for n in range(2, 53):
the_date = the_date + timedelta(days=7)
print "%d. %s" % (n, the_date)
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to increment date by week? PieGuy <r90230@gmail.com> - 2013-06-04 14:31 -0700 Re: How to increment date by week? Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-04 22:44 +0100 Re: How to increment date by week? Tim Chase <python.list@tim.thechases.com> - 2013-06-04 16:50 -0500 Re: How to increment date by week? John Gordon <gordon@panix.com> - 2013-06-04 21:48 +0000 Re: How to increment date by week? Giorgos Tzampanakis <giorgos.tzampanakis@gmail.com> - 2013-06-04 21:47 +0000 RE: How to increment date by week? Carlos Nepomuceno <carlosnepomuceno@outlook.com> - 2013-06-05 01:52 +0300 Re: How to increment date by week? Skip Montanaro <skip@pobox.com> - 2013-06-04 20:17 -0500 Re: How to increment date by week? steve.ferg.bitbucket@gmail.com - 2013-06-04 20:43 -0700 Re: How to increment date by week? PieGuy <r90230@gmail.com> - 2013-06-05 09:39 -0700
csiph-web