CString Format( DWORD dwFlags = 0, LCID lcid = LANG_USER_DEFAULT );
CString Format( LPCTSTR lpszFormat ) const;
CString Format( UINT nFormatID ) const;
Return Value
A CString that contains the formatted date/time value.
Parameters
dwFlags
Indicates flags for locale settings, possibly the following flag:
lcid
Indicates locale ID to use for the conversion.
lpszFormat
A formatting string similar to the printf formatting string. Formatting codes, preceded by a percent (%) sign, are replaced by the corresponding COleDateTime component. Other characters in the formatting string are copied unchanged to the returned string. See the run-time function strftime for details. The value and meaning of the formatting codes for Format are listed below:
nFormatID
The resource ID for the format-control string.
Remarks
Call this member function to create a formatted representation of the date/time value. If the status of this COleDateTime object is null, the return value is an empty string. If the status is invalid, the return string is specified by the string resource IDS_INVALID_DATETIME.
A brief description of the three forms for this function follows:
Format( dwFlags, lcid )
This form formats the value using the national language specifications (locale IDs) for date/time. Using the default parameters, this form will print a time only if the date portion of the date/time value is date 0 (30 December 1899). Similarly, with the default parameters, this form will print a date only if the time portion of the date/time value is time 0 (midnight). If the date/time value is 0 (30 December 1899, midnight), this form with the default parameters will print midnight.
Format( lpszFormat )
This form formats the value using the format string which contains special formatting codes that are preceded by a percent sign (%), as in printf. The formatting string is passed as a parameter to the function. For more information about the formatting codes, see strftime, wcsftime in the Run-Time Library Reference.
Format( nFormatID )
This form formats the value using the format string which contains special formatting codes that are preceded by a percent sign (%), as in printf. The formatting string is a resource. The ID of this string resource is passed as the parameter. For more information about the formatting codes, see strftime, wcsftime in the Run-Time Library Reference.
For a listing of locale ID values, see the section Supporting Multiple National Languages in the Win32 SDK OLE Programmer’s Reference.
Example
COleDateTime t(1999, 3, 19, 22, 15, 0);
CString str = t.Format(_T("%A, %B %d, %Y"));
ASSERT(str == _T("Friday, March 19, 1999"));
COleDateTime Overview | Class Members | Hierarchy Chart
See Also COleDateTime::ParseDateTime, COleDateTime::GetStatus