Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46980
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <carlosnepomuceno@outlook.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.076 |
| X-Spam-Evidence | '*H*': 0.85; '*S*': 0.00; 'f.close()': 0.09; 'subject:How': 0.10; '2.7': 0.14; 'bonus.': 0.16; 'increment': 0.16; 'received:65.55.116.7': 0.16; 'index': 0.16; 'numerical': 0.19; 'subject:week': 0.19; 'import': 0.22; 'to:name:python- list@python.org': 0.22; 'received:65.55.116': 0.24; 'skip:% 10': 0.24; 'file.': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'front': 0.32; 'date:': 0.34; 'skip:d 20': 0.34; 'could': 0.34; 'skip:f 40': 0.36; 'subject:?': 0.36; 'email addr:python.org': 0.37; 'starting': 0.37; 'to:addr:python-list': 0.38; 'list,': 0.38; 'subject:': 0.39; 'moving': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'save': 0.62; 'email addr:gmail.com': 0.63; 'skip:6 10': 0.63; 'today': 0.64; 'email name:python-list': 0.65; 'date,': 0.68; 'day': 0.76; '2013': 0.98 |
| X-TMN | [udtrYmiRU9ULEsv0nlIDTAmFa7jtdmwm] |
| X-Originating-Email | [carlosnepomuceno@outlook.com] |
| Content-Type | multipart/alternative; boundary="_0b9db2bb-b75f-404f-933d-a874894c9294_" |
| From | Carlos Nepomuceno <carlosnepomuceno@outlook.com> |
| To | "python-list@python.org" <python-list@python.org> |
| Subject | RE: How to increment date by week? |
| Date | Wed, 5 Jun 2013 01:52:01 +0300 |
| Importance | Normal |
| In-Reply-To | <b07dac48-1479-42cc-908c-21a3b2e14198@googlegroups.com> |
| References | <b07dac48-1479-42cc-908c-21a3b2e14198@googlegroups.com> |
| MIME-Version | 1.0 |
| X-OriginalArrivalTime | 04 Jun 2013 22:52:02.0094 (UTC) FILETIME=[20942CE0:01CE6176] |
| 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 | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2689.1370386330.3114.python-list@python.org> (permalink) |
| Lines | 68 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1370386330 news.xs4all.nl 15943 [2001:888:2000:d::a6]:33882 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:46980 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
> Date: Tue, 4 Jun 2013 14:31:07 -0700
> Subject: How to increment date by week?
> From: r90230@gmail.com
> To: python-list@python.org
>
> 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
YAS:
import datetime
today = datetime.datetime.today()
week = datetime.timedelta(weeks=1)
f=open('output.txt','w')
for i in range(52):
f.write((today+i*week).strftime(str(i+1)+'. %Y-%m-%d\n'))
f.close()
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