[egenix-users] mxDateTime puzzle

Charlie Clark charlie at egenix.com
Fri May 2 14:48:18 CEST 2008


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")
'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'

Charlie

-- 
Charlie Clark
eGenix.com

Professional Python Services directly from the Source
>>> Python/Zope Consulting and Support ...        http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::

     eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
            Registered at Amtsgericht Duesseldorf: HRB 46611



More information about the egenix-users mailing list