[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: strange python datetime issue on people.apache.org

From: Greg Stein <gstein_at_gmail.com>
Date: Fri, 14 May 2010 21:34:47 -0400

On Fri, May 14, 2010 at 20:56, Dongsheng Song <dongsheng.song_at_gmail.com> wrote:
> Hi forks,
>
> On my windows box (UTC+8), the following python code give me 22724
> (python 2.6.5 or 3.1.2), but on people.apache.org
>
> (python 2.6.4), I got
> :22722:
>
> from datetime import datetime;
> dt = datetime.now() - datetime(2000, 1, 1, 0, 0, 0);
> round((dt.days * 24 + dt.seconds / 3600) / 4)

Well, first you want to ensure that you're performing that math using
floating point values, since dt.days and dt.seconds are integers.
Thus:

round((dt.days * 24. + dt.seconds / 3600.) / 4)

In any case, it looks like you're counting the number of 4-hour
periods since January 1, 2000. people.apache.org is in a different
time zone, so it is reporting a different number of hours. That's all.

btw, in Python, you don't really want/need those trailing semicolons :-)

Cheers,
-g
Received on 2010-05-15 03:35:15 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.