CTimeSpan::Format

Syntax

CString Format( const char* pFormat );

Parameters

pFormat

Indicates a formatting string similar to the printf formatting string. Formatting codes, preceded by a percent (%) sign, are replaced by the corresponding CTimeSpan component. Other characters in the formatting string are copied unchanged to the returned string.

The formatting codes for Format are listed below:

Value Meaning

%D Total days in this CTimeSpan
%H Hours in the current day
%M Minutes in the current hour
%S Seconds in the current minute
%% Percent sign

Remarks

Generates a formatted string that corresponds to this CTimeSpan.

The Debug version of the library checks the formatting codes and asserts if the code is not in the table above.

Return Value

A CString object that contains the formatted time.

Example

CTimeSpan ts( 3, 1, 5, 12 ); // 3 days, 1 hour, 5 min, and 12 sec

CString s = ts.Format( "Total days: %D, hours: %H, min: %M, sec: %S" );

ASSERT( s == "Total days: 3, hours: 01, min: 05, sec: 12" );