Confused.

Alex Martelli aleaxit at yahoo.com
Sat Nov 11 17:50:22 EST 2000


"Syver Enstad" <syver.enstad at sensewave.com> wrote in message
news:8ujvgv$ne$1 at troll.powertech.no...
>
> "Alex Martelli" <aleaxit at yahoo.com> wrote in message
> news:8ujqao029t5 at news1.newsguy.com...
> > gbreed's alternative suggestion was:
> >
> > > > import pywintypes, time
> > > > comtime = pywintypes.Time(time.time())
>
> What you're trying to say is that the constructor of Time, converts from
> time.time() format to a PyTime object, and you use float on the PyTime to
> get the variant_date or whatever the COM date type is called. Right?.

Right, AFAIK.

> But there is still no function to convert from comtime to ctime format is
> there?

int() on a pywintypes.PyTime object gives 'ctime', as you call
it.  I.e.,

>>> a=pywintypes.Time(0)
>>> float(a)
25569.041666666668
>>> int(a)
0
>>>

(Yeah, I agree that's not very intuitive:-).


> An interesting bug by the way:
> >>> import pywintypes, time
> >>> ctime = time.time()
> >>> comtime = pywintypes.Time(ctime)
>
> I'll think I'll stick to the time module or I'll have to go to work
tomorrow
> ;-)
> >>> time.ctime(ctime)
> 'Sat Nov 11 17:59:33 2000'
> >>> comtime.Format('%#c')
> 'Sunday, November 11, 2000 17:59:33'

Pretty buggy, yes...!


Alex






More information about the Python-list mailing list