Kbase 17982: ACTIVEX - Extracting TIME Value From DateTime Property
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  16/10/2008 |
|
Status: Unverified
GOAL:
How to extract the time component from a COM method/property returning a DATETIME value ?
FACT(s) (Environment):
Progress 8.x
Progress 9.x
FIX:
Some ActiveX Controls and ActiveX automation servers (such as Microsoft Outlook) have properties whose values are compound date/time stamps. It may be desired to extract the time component of this date/time value.
Up to Progress version 9, The Progress 4GL supports only the DATE datatype (that is, there is no TIME datatype, nor a DATETIME datatype). If an application uses 4GL code to read a date/time property from a COM object, the 4GL interpreter will convert that value to a straight DATE value, and will discard the time component. This poses a problem for applications that want to get at the time component.
To extract the time portion of a COM date/time value, external code (e.g. a DLL) to be called from the 4GL application is required; this code would access the date/time property and extract the time value, then return the time value to the 4GL application.
For example, a DLL function could be written that took two input parameters:
- 4GL COM-HANDLE to the COM object that has the date/time property
- character string containing the name of the property and returned two output parameters:
- a 4GL DATE value containing the date component of the date/time
- a 4GL character string containing the time component (e.g. "14:08.34") Other ways of returning the time component might make more sense for certain applications, rather than using a character string (e.g. use three separate output INTEGER parameters, one each for hours, minutes and seconds).
The code in the DLL would call the COM INVOKE method on the COM-HANDLE to obtain the value of the date/time property, extract the date and time components separately and return them to the 4GL application. The extraction algorithm would depend on how the COM object had encoded the date/time value; the standard encoding stores the date/time as a double floating-point value that contains:
- the number of days since December 30, 1899 in the whole part, and
- the time in the fractional part (expressed as a fraction of a day) The DLL would be written in C++ or possibly Visual Basic. There are no plans from Progress to write such a DLL as an officially supported utility; the DLL will have to be developed by the Progress users themselves.