Conversion from WTime to WDate and vice versa does not work.
To fix this, the following OLE-functions can be used:
WTime time;
WDate date;
::SystemTimeToVariantTime( (const SYSTEMTIME *)&time, &date );
::VariantTimeToSystemTime( date, (SYSTEMTIME *)&time );
The functions are prototyped in oleauto.h, which is included with windows.h.
Also the oleaut32.lib must be added to project.
// Code added here will be included at the top of the .CPP file
#pragma library("oleaut32.lib")
In both functions the milliseconds are cut off. To avoid it, the following portable conversion can be used:
#include <math.h>
static const WDouble WDateMillisecondsADay = 24. * 60. * 60. * 1000.;
void TimeToDate( const WTime & time, WDate & date )
void DateToTime( WDate date, WTime & time )
{
::SystemTimeToVariantTime(( const SYSTEMTIME *)&time, &date );
date += ( WDouble( time.milliSeconds ) / WDateMillisecondsADay);
}
{
::VariantTimeToSystemTime(date, (SYSTEMTIME *)&time) ;
WDouble integral;
WDouble fractional = modf( date, &integral );
time.milliSeconds = WShort( WLong( floor( fractional * WDateMillisecondsADay + .5) ) % 1000);
}
The bug exists in Power 2.5 beta, 2.1 and probably in all previous versions.