COleDateTimeSpan::Format

CString Format( LPCTSTR pFormat ) const;

CString Format( UINT nID ) const;

Return Value

A CString that contains the formatted date/time-span value.

Parameters

pFormat

A formatting string similar to the printf formatting string. Formatting codes, preceded by a percent (%) sign, are replaced by the corresponding COleDateTimeSpan 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:

nID

The resource ID for the format-control string.

Remarks

Call these functions to create a formatted representation of the time-span value. If the status of this COleDateTimeSpan 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_DATETIMESPAN.

A brief description of the forms for this function follows:

Format( pFormat )

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.

Format( nID )

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 used in this function, 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

// get the current time
COleDateTime tmStart = COleDateTime::GetCurrentTime();

// waste some time
CString str;
::Sleep(3000);

// get the current time again
COleDateTime tmFinish = COleDateTime::GetCurrentTime();

// find the difference
COleDateTimeSpan tmSpan = tmFinish - tmStart;

// tell the user
str = tmSpan.Format(_T("%S seconds elapsed"));
_tprintf(_T("%s\n"), (LPCTSTR) str);

COleDateTimeSpan OverviewClass MembersHierarchy Chart

See Also   COleDateTimeSpan::GetStatus