Create pywintypes.Time from an mx.DateTime.DateTime

Michael Weiss FooWeissBarMike at hotmail.com
Fri May 24 13:45:16 EDT 2002


This works great...

---
import pywintypes, types, mx.DateTime

mxtime = mx.DateTime.Date(2050)
print mxtime.Format() #prints "01/01/50 00:00:00" which is right

comtime = pywintypes.Time(mxtime.tuple())
print comtime.Format() #prints "01/01/50 00:00:00" which is also right!
---

Now I get a nicely typed (VT_DATE) variant back in my (active scripting)
hosting application.

Thanks! I started to look at the python win32 C code in CVS (at
pythonpros.com)...
Thankfully you replyed before having to decifer too much of PyTime.cpp!!


"Mark Hammond" <mhammond at skippinet.com.au> wrote in message
news:3CEE5B7D.7080308 at skippinet.com.au...
> Mike Weiss wrote:
> > I'm *very* new to python (C++ programmer)  so please bear with me if
> > what
> > I'm asking is completely stupid.
> > I'm using both mxDateTime and the win32 extensions in python v2.2.
> >
> > I'm trying to create a pywintypes.Time (a window's COM date (right?))
> > FROM
> > an mx.DateTime object. I can go the other way (pywintypes TO
> > mxDateTime).
> >
> > mx.DateTime.COMDate() returns a float, which I can't seem to use to
> > initalize a pywintypes.Time object with. Pywintypes.Time only seems to
> > be
> > able to be created from the integer value used by the basic "time"
> > module in standard python.
>
> It can also be initialized with a standard Python "time tuple", as used
> by the time module.  I am not sure of the semantics of the mx objects,
> but I am sure they would allow you to get such a tuple very simply.
>
> Mark.
>





More information about the Python-list mailing list