Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.83.MISMATCH!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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'float': 0.05; 'allowed.': 0.07; 'subject:two': 0.07; 'supported,': 0.07; 'subject:How': 0.09; 'python': 0.09; 'be:': 0.09; 'supported.': 0.09; '3.3,': 0.16; 'roy': 0.16; 'subject:weeks': 0.16; 'wrote:': 0.17; 'jan': 0.18; 'seems': 0.23; 'header:In-Reply-To:1': 0.25; 'appear': 0.26; 'supported': 0.26; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'division': 0.29; 'function.': 0.33; 'to:addr:python-list': 0.33; 'operations': 0.33; 'weeks': 0.33; 'another': 0.33; 'version': 0.34; 'changed': 0.34; 'received:google.com': 0.34; 'pm,': 0.35; 'received:209.85.220': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'two': 0.37; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'smith': 0.71; '2.7.': 0.84; '2013': 0.84; 'are?': 0.84; 'subject:tell': 0.84; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=qnE3jTGEXkFxetKK/26nOWAnmMh61TQs3fdMkbdC9Ug=; b=Zvpvcfhergmg+q459G5ac+YtAdZxMPTQpfZRh5B7Y375QB3pEY0Wt9fScH/9lktWuD P7RUeEwBhyCeksay9eEsU10UX+8AqG4GMrUrK5+yps63D7nfc5M97YoO+YK7CLjQgwET 8nY3OLHmHVD/kiqidurw/uRtNYJmL/nS4dTNdjmtvF8IRPwj/HNIHS1hrwR00QqQCk1H MM25hxWLcNuK45e7LBx/VrlSC+z87Q0Ioc6LLgRwQGC3BtfxT7s7qfntetfBkyNigDaU Q+DM6mrVZXGNPXeuMBQub9ta/2SZY24/ux3zJ3APhHJU/HO5Qd5tuBcSCqk9iBqXKfA+ xk4A== MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Tue, 8 Jan 2013 14:36:08 -0700 Subject: Re: How to tell how many weeks apart two datetimes are? To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357681002 news.xs4all.nl 6974 [2001:888:2000:d::a6]:51029 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36454 On Tue, Jan 8, 2013 at 2:33 PM, Ian Kelly wrote: > On Tue, Jan 8, 2013 at 2:22 PM, Roy Smith wrote: >> How do you tell how many weeks apart two datetimes (t1 and t2) are? >> The "obvious" solution would be: >> >> weeks = (t2 - t1) / timedelta(days=7) >> >> but that doesn't appear to be allowed. Is there some fundamental >> reason why timedelta division not supported? > > Seems to be supported in Python 3.3, but not in 2.7. >From the docs: Changed in version 3.2: Floor division and true division of a timedelta object by another timedelta object are now supported, as are remainder operations and the divmod() function. True division and multiplication of a timedelta object by a float object are now supported.