CTimeSpan::CTimeSpan

Constructs CTimeSpan objects in various ways.

CTimeSpan( ) throw( );
CTimeSpan(
   __time64_t time 
) throw( );
CTimeSpan(
   LONG lDays,
   int nHours,
   int nMins,
   int nSecs 
) throw( );

Parameters

  • timeSpanSrc
    A CTimeSpan object that already exists.

  • time
    A __time64_t time value, which is the number of seconds in the time span. In Visual C++ versions 6.0 and earlier, time was a value of time_t. Visual C++ .NET or later silently converts a time_t parameter to __time64_t.

  • lDays, nHours, nMins, nSecs
    Days, hours, minutes, and seconds, respectively.

Remarks

All these constructors create a new CTimeSpan object initialized with the specified relative time. Each constructor is described below:

  • CTimeSpan( );   Constructs an uninitialized CTimeSpan object.

  • CTimeSpan( const CTimeSpan& );   Constructs a CTimeSpan object from another CTimeSpan value.

  • CTimeSpan( __time64_t );   Constructs a CTimeSpan object from a __time64_t type.

  • CTimeSpan( LONG, int, int, int );   Constructs a CTimeSpan object from components with each component constrained to the following ranges:

    Component

    Range

    lDays

    0–25,000 (approximately)

    nHours

    0–23

    nMins

    0–59

    nSecs

    0–59

Note that the Debug version of the Microsoft Foundation Class Library asserts if one or more of the time-day components is out of range. It is your responsibility to validate the arguments prior to calling.

Example

CTimeSpan ts1;  // Uninitialized time value
CTimeSpan ts2a(ts1); // Copy constructor
CTimeSpan ts2b = ts1; // Copy constructor again
CTimeSpan ts3(100); // 100 seconds
CTimeSpan ts4(0, 1, 5, 12);    // 1 hour, 5 minutes, and 12 seconds   

Requirements

Header: atltime.h

See Also

Reference

CTimeSpan Class

Hierarchy Chart

Other Resources

CTimeSpan Members