Mailing List Archive

COM dates
Hello,

I have a COM object with a field calles "StartDate". When I type:

print Obj.StartDate, I get:

<PyTime:1/1/70 12:00:00 AM>

Two questions:

1) What is that PyTime object? Is it documented somewhere?

2) Suppose I want to set StartDate to January 1, 1999, what do I write in my
script?

Thanks in advance!
______________________________________________________
Gaetan Corneau
Software Developer (System integration Team)
BaaN Supply Chain Solutions
E-mail: Gaetan_Corneau@baan.com
Compuserve: Gaetan_Corneau@compuserve.com
ICQ Number: 7395494
Tel: (418) 654-1454 ext. 252
______________________________________________________
"Profanity is the one language all programmers know best"
COM dates [ In reply to ]
Check out the win32 extensions help file. This has a discussion of COM
dates. In a nutshell, you use the int() function to convert it to a
standard Python time module date, and you can assign a standard Python time
module date to a COM date field and it will do the right thing.

Mark.

Gaetan Corneau wrote in message
<816010E2456BD111A48700805FBBE2EEFDF353@ex-quebec-u1.baan.com>...
>Hello,
>
>I have a COM object with a field calles "StartDate". When I type:
>
>print Obj.StartDate, I get:
>
><PyTime:1/1/70 12:00:00 AM>
>
>Two questions:
>
>1) What is that PyTime object? Is it documented somewhere?
>
>2) Suppose I want to set StartDate to January 1, 1999, what do I write in
my
>script?
COM dates [ In reply to ]
Thanks Mark!

Another question: why no "strptime" function under WIN32? This function is
not, as far as I know, difficult to implement.

Tnanks again,
______________________________________________________
Gaetan Corneau
Software Developer (System integration Team)
BaaN Supply Chain Solutions
E-mail: Gaetan_Corneau@baan.com
Compuserve: Gaetan_Corneau@compuserve.com
ICQ Number: 7395494
Tel: (418) 654-1454 ext. 252
______________________________________________________
"Profanity is the one language all programmers know best"

> -----Original Message-----
> From: Mark Hammond [SMTP:MHammond@skippinet.com.au]
> Sent: Wednesday, June 09, 1999 6:41 PM
> To: python-list@cwi.nl
> Subject: Re: COM dates
>
> Check out the win32 extensions help file. This has a discussion of COM
> dates. In a nutshell, you use the int() function to convert it to a
> standard Python time module date, and you can assign a standard Python
> time
> module date to a COM date field and it will do the right thing.
>
> Mark.
>
COM dates [ In reply to ]
Gaetan Corneau wrote in message
<816010E2456BD111A48700805FBBE2EEFDF354@ex-quebec-u1.baan.com>...
>Thanks Mark!
>
>Another question: why no "strptime" function under WIN32? This function is
>not, as far as I know, difficult to implement.

Because it doesnt exist in the raw MS CRTL, and no one has offered a
replacement.

Mark.
COM dates [ In reply to ]
Gaetan Corneau wrote:
>
> Another question: why no "strptime" function under WIN32? This function is
> not, as far as I know, difficult to implement.

You could check out mxDateTime. It has COM date support, strptime()
and also a much more powerful date/time parser:

http://starship.skyport.net/~lemburg/mxDateTime.html

Not sure how you would convert the Win32 PyTime objects into
DateTime objects though. If they implement the int() APIs, then
DateTimeFromTicks(pyTime) will do, otherwise there's also a
constructor DateTimeFromCOMDate(comdate) which takes the raw
COM date float as argument.

Mark ?

--
Marc-Andre Lemburg
______________________________________________________________________
Y2000: 204 days left
Business: http://www.lemburg.com/
Python Pages: http://www.lemburg.com/python/
COM dates [ In reply to ]
I did it the Python way: I looked at what I really needed, looked at the
documentation to see what I had, and wrote a 3 line function that takes
year, month, date, hour, minute and second and returns time in the same
numeric format as time.time().

I knew about mxDateTime and think it's really cool (I have written something
similar in C++ years ago), but for many reasons, I don't want to rely on
extensions for this particular project.


Thanks,
______________________________________________________
Gaetan Corneau
Software Developer (System integration Team)
BaaN Supply Chain Solutions
E-mail: Gaetan_Corneau@baan.com
Compuserve: Gaetan_Corneau@compuserve.com
ICQ Number: 7395494
Tel: (418) 654-1454 ext. 252
______________________________________________________
"Profanity is the one language all programmers know best"

> -----Original Message-----
> From: M.-A. Lemburg [SMTP:mal@lemburg.com]
> Sent: Thursday, June 10, 1999 4:31 AM
> To: Gaetan Corneau
> Cc: Python List @ Python.org
> Subject: Re: COM dates
>
>
> You could check out mxDateTime. It has COM date support, strptime()
> and also a much more powerful date/time parser:
>
COM dates [ In reply to ]
M.-A. Lemburg wrote in message <375F77C1.629FED7B@lemburg.com>...

>Not sure how you would convert the Win32 PyTime objects into
>DateTime objects though. If they implement the int() APIs, then
>DateTimeFromTicks(pyTime) will do, otherwise there's also a
>constructor DateTimeFromCOMDate(comdate) which takes the raw
>COM date float as argument.

"Win32 PyTime" dates and "COM dates" are the same thing. Although COM uses
them most heavily, we decided to move the date support into the Win32
extensions, so everyone can use them. (Specifically, they are implemented
in pywintypes15.dll, along with our Unicode objects, HANDLE objects, UUID
objects, etc)

FWIW, I personally use mxDateTime whenever I hit the many limitations in
Python dates. As Marc said, I used DateTimeFromCOMDate, then work with the
DateTime object. Can''t recall exactly how I convert it back, but it is
definately there.

Mark.