Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; '%s"': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; '-tkc': 0.16; 'bonus.': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'index': 0.16; 'wrote:': 0.18; 'numerical': 0.19; 'subject:week': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'front': 0.32; 'skip:d 20': 0.34; 'could': 0.34; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'starting': 0.37; 'list,': 0.38; 'skip:6 10': 0.63; 'to:addr:gmail.com': 0.65; 'date,': 0.68; 'day': 0.76; 'received:50.22': 0.84 Date: Tue, 4 Jun 2013 16:50:03 -0500 From: Tim Chase To: PieGuy Subject: Re: How to increment date by week? In-Reply-To: References: X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1370382496 news.xs4all.nl 16009 [2001:888:2000:d::a6]:59057 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46974 On 2013-06-04 14:31, PieGuy wrote: > 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. import datetime start = datetime.date.today() for i in range(53): dt = start + datetime.timedelta(days=7*i) result = "%i. %s" % ( i+1, dt.strftime('%m/%d/%Y') ) do_something_with(result) -tkc