BOOL ParseDateTime( LPCTSTR lpszDate, DWORD dwFlags = 0, LCID lcid = LANG_USER_DEFAULT );
throw( CMemoryException );
throw( COleException );
Return Value
Nonzero if the string was successfully converted to a date/time value, otherwise 0.
Parameters
lpszDate
A pointer to the null-terminated string which is to be parsed. For details, see Remarks.
dwFlags
Indicates flags for locale settings and parsing. One or more of the following flags:
lcid
Indicates locale ID to use for the conversion.
Remarks
Call this member function to parse a string to read a date/time value. If the string was successfully converted to a date/time value, the value of this COleDateTime object is set to that value and its status to valid.
Note Year values must lie between 100 and 9999, inclusively.
The lpszDate parameter can take a variety of formats. For example, the following strings contain acceptable date/time formats:
"25 January 1996"
"8:30:00"
"20:30:00"
"January 25, 1996 8:30:00"
"8:30:00 Jan. 25, 1996"
"1/25/1996 8:30:00" // always specify the full year,
// even in a 'short date' format
Note that the locale ID will also affect whether the string format is acceptable for conversion to a date/time value.
In the case of VAR_DATEVALUEONLY, the time value is set to time 0, or midnight. In the case of VAR_TIMEVALUEONLY, the date value is set to date 0, meaning 30 December 1899.
If the string could not be converted to a date/time value or if there was a numerical overflow, the status of this COleDateTime object is invalid.
If the string conversion failed due to memory allocation errors, this function throws a CMemoryException. In any other error state, this function throws a COleException.
For a listing of locale ID values, see the section Supporting Multiple National Languages in the Win32 SDK OLE Programmer’s Reference.
For more information about the bounds and implementation for COleDateTime values, see the article Date and Time: Automation Support in Visual C++ Programmer’s Guide.
COleDateTime Overview | Class Members | Hierarchy Chart
See Also COleDateTime::Format, COleDateTime::GetStatus