RE: Day of Year Behaviour
From: Robert Brewer (fumanchu_at_amor.org)
Date: 10/01/04
- Next message: Joachim Dahl: "python latex class and math environment"
- Previous message: David Bolen: "Re: "False exceptions?" (was Re: theme of the week: tools"
- Maybe in reply to: Hector Villafuerte: "Day of Year Behaviour"
- Next in thread: Anna Martelli Ravenscroft: "Re: Day of Year Behaviour"
- Reply: Anna Martelli Ravenscroft: "Re: Day of Year Behaviour"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Sep 2004 16:16:17 -0700 To: "Hector Villafuerte" <hecvillaf@yahoo.com>, <python-list@python.org>
Hector Villafuerte wrote:
> I have 2 fields:
> YEAR
> DAY_OF_YEAR
>
> and I need to get the complete date out of this, e.g.:
> YEAR=2004
> DAY_OF_YEAR=1
> -> DATE=2004/Jan/1
>
> YEAR=2004
> DAY_OF_YEAR=33
> -> DATE=2004/Feb/2
>
> I'm using the time module without success:
> >>> time.localtime(time.mktime((2004, 0, 0, 0, 0, 0, 0, 1, 0)))
> (2003, 11, 30, 0, 0, 0, 6, 334, 0)
One way to do it:
>>> import datetime
>>> YEAR = 2004
>>> DAY_OF_YEAR = 33
>>> d = datetime.date(YEAR, 1, 1) + datetime.timedelta(DAY_OF_YEAR - 1)
>>> d
datetime.date(2004, 2, 2)
Robert Brewer
MIS
Amor Ministries
fumanchu@amor.org
- Next message: Joachim Dahl: "python latex class and math environment"
- Previous message: David Bolen: "Re: "False exceptions?" (was Re: theme of the week: tools"
- Maybe in reply to: Hector Villafuerte: "Day of Year Behaviour"
- Next in thread: Anna Martelli Ravenscroft: "Re: Day of Year Behaviour"
- Reply: Anna Martelli Ravenscroft: "Re: Day of Year Behaviour"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]