[python-win32] PyTime

Francesco Guerrieri f.guerrieri at gmail.com
Tue May 8 14:59:50 CEST 2007


thanks :)
I resorted to your solution:

for i in DataList:
        OutputList.append(datetime.date(int(i.Format("%Y")),
int(i.Format("%m")),
int(i.Format("%d"))))
    return OutputList

and it works. I am considering dates up to 50 years from now so 2038 is
definitely too early :-)

Francesco

On 5/8/07, Tim Golden <mail at timgolden.me.uk> wrote:
>
> Mark Mc Mahon wrote:
> > Hi,
> >
> > Maybe there is a better way then this suggestion...
> >
> > from datetime import datetime
> >
> > date = <some PyTime object>
> >
> > day = int(xl.activecell.value.Format("%d"))
> > month = int(xl.activecell.value.Format("%m"))
> > year = int(xl.activecell.value.Format("%Y"))
> >
> > date_as_datetime = datetime(year, month, day)
>
> Frankly, I can't think of anything better. You
> might combine PyTime.Format and datetime.strptime,
> or do some kind of integer combination thing
> with the three values, but nothing's too
> compelling.
>
> Maybe the OP might be interested in xlrd or
> PyExcelerator (assuming they handle dates
> a little better).
>
> > PyTime is starting to look like a wart :-)
> > Is it a hold over from when
> > datetime didn't exist?
>
> Think so; guess Mark's had no incentive to change
> things, and I imagine it would be non-trivial to
> rework all the PyTimes into datetimes. Maybe, though
> a new method might be added? (Sadly, though, I'm
> in no position to offer, and I don't really have
> an itch to scratch, either).
>
> TJG
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20070508/402517b5/attachment.html 


More information about the Python-win32 mailing list