mxDateTime package question
Eddie Corns
eddie at holyrood.ed.ac.uk
Wed Oct 13 06:27:53 EDT 2004
prashant_pai at yahoo.com (Prashant Pai) writes:
>I have a Julian (?) date string '2000238' (format YYYYDDD) which
>corresponds to 2000/08/25
>How do I create a correct DateTime object with this?
Logically you could do:
>>> import mx.DateTime
>>> mx.DateTime.strptime('2000238','%Y%j')
<DateTime object for '2000-08-25 00:00:00.00' at 403ae410>
However that doesn't work on all systems. Works on my Linux systems but not
my BSD ones :( Depends on the C implementation of strptime which has never
been 100%
Probably better to do:
year,day = ...
mx.DateTime.strptime(year,'%Y') + int(day) - 1
eg:
>>> mx.DateTime.strptime('2000','%Y')+237
<DateTime object for '2000-08-25 00:00:00.00' at 4039c138>
which is more portable.
Eddie
More information about the Python-list
mailing list