[egenix-users] mxDateTime puzzle

Dick Moores rdmoores at gmail.com
Fri May 2 06:44:18 CEST 2008


On Fri, May 2, 2008 at 4:48 AM, Charlie Clark <charlie at egenix.com> wrote:
> Am 02.05.2008, 13:44 Uhr, schrieb Dick Moores <rdmoores at gmail.com>:
>
>> On Fri, May 2, 2008 at 4:37 AM, Charlie Clark <charlie at egenix.com> wrote:
>>>
>>> Am 02.05.2008, 13:24 Uhr, schrieb Dick Moores <rdmoores at gmail.com>:
>>>
>>>> Sorry, my mistake.
>>>> I'm not sure I understand your
>>>>>
>>>>> problem. Do you need to display the dates in US-format.
>>>>
>>>> Not sure exactly what you mean by US-format. What I want is '5/1/2008'
>>>> or '05/01/2008' for May 1, 2008.
>>>
>>> That is how it's being parsed. mx.DateTime always represents dates using
>>> the
>>> ISO format YYYY-MM-DD to try and avoid such ambiguities.
>>
>> So there's no way to print the result of date + n  in the form I want?
>>
>> If you looked at <http://py77.python.pastebin.com/f25c957>
>>
>> You'll see I succeeded in this using datetime:
>>
>> Enter date as month/day/year, or enter nothing for today: 1/1/2009
>> Date entered was 01/01/2009
>> Enter positive int for days after date; negative int for days before date.
>> Enter the number of days: -200
>> 01/01/2009 minus 200 days is 06/15/2008
>>
>> Dick
>
> Sure, tell it the format you want just with datetime
>
>>>> a.strftime("%m/%d/%Y")


No, that fails for year < 1900

>
> '03/03/2008'
>>>>
>>>> a + 15
>
> <mx.DateTime.DateTime object for '2008-03-18 00:00:00.00' at 108fad8>
>>>>
>>>> _.strftime('%m/%d/%Y')
>
> '03/18/2008'


Yes, I've got it now! See <http://py77.python.pastebin.com/f7082fb>

Thanks for your help, Charlie.

Dick



More information about the egenix-users mailing list