mxDateTime package question
Steve Holden
steve at holdenweb.com
Tue Oct 12 21:00:42 EDT 2004
Prashant Pai wrote:
> 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?
>
> thanks
You could try
>>> jd = "2000238"
>>> y = int(jd[:4])
>>> d = int(jd[4:])-1
>>> yd = mx.DateTime.DateTime(y)
>>> dinc = mx.DateTime.DateTimeDeltaFromDays(d)
>>> result = yd+dinc
>>> result
<DateTime object for '2000-08-25 00:00:00.00' at a0d4620>
>>>
but there may well be more efficient ways.
regards
Steve
--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
More information about the Python-list
mailing list