Converts a system time to a variant representation.
INT SystemTimeToVariantTime( LPSYSTEMTIME lpSystemTime, double *pvtime );
The function returns one of the following:
Value | Meaning |
---|---|
zero | Failure. |
non-zero | Success. |
A variant time is stored as an 8-byte real value (double), representing a date between January 1, 100 and December 31, 9999, inclusive. The value 2.0 represents January 1, 1900; 3.0 represents January 2, 1900, and so on. Adding 1 to the value increments the date by a day. The fractional part of the value represents the time of day. Therefore, 2.5 represents noon on January 1, 1900; 3.25 represents 6:00 A.M. on January 2, 1900, and so on. Negative numbers represent dates prior to December 30, 1899.
The variant time resolves to one second. Any milliseconds in the input date are ignored.
The LPSYSTEMTIME structure is useful for the following reasons:
The SystemTimeToVariantTime function will accept invalid dates and try to fix them when resolving to a VARIANT time. For example, an invalid date such as 2/29/2001 will resolve to 3/1/2001. Only days are fixed, so invalid month values result in an error being returned. Days are checked to be between 1 and 31. Negative days and days greater than 31 results in an error. A day less than 31 but greater than the maximum day in that month has the day promoted to the appropriate day of the next month. A day equal to zero resolves as the last day of the previous month. For example, an invalid dates such as 2/0/2001 will resolve to 1/31/2001.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 OSR2 or later.
Header: Declared in oleauto.h.
Library: Use oleaut32.lib.
VariantTimeToSystemTime
Converts the variant representation of time to system time values.
INT VariantTimeToSystemTime( double vtime, LPSYSTEMTIME lpSystemTime );
The return value obtained from the returned INT is one of the following.
Value | Meaning |
---|---|
TRUE | Success. |
FALSE | Failure. |
A variant time is stored as an 8-byte real value (double), representing a date between January 1, 100 and December 31, 9999, inclusive. The value 2.0 represents January 1, 1900; 3.0 represents January 2, 1900, and so on. Adding 1 to the value increments the date by a day. The fractional part of the value represents the time of day. Therefore, 2.5 represents noon on January 1, 1900; 3.25 represents 6:00 A.M. on January 2, 1900, and so on. Negative numbers represent the dates prior to December 30, 1899.
Using the SYSTEMTIME structure is useful because:
The VariantTimeToSystemTime function will accept invalid dates and try to fix them when resolving to a VARIANT time. For example, an invalid date such as 2/29/2001 will resolve to 3/1/2001. Only days are fixed, so invalid month values result in an error being returned. Days are checked to be between 1 and 31. Negative days and days greater than 31 results in an error. A day less than 31 but greater than the maximum day in that month has the day promoted to the appropriate day of the next month. A day equal to zero resolves as the last day of the previous month. For example, an invalid dates such as 2/0/2001 will resolve to 1/31/2001.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 OSR2 or later.
Header: Declared in oleauto.h.
Library: Use oleaut32.lib.