system_clock Structure

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at system_clock Structure.

Represents a clock type that is based on the real-time clock of the system.

struct system_clock;  

A clock type is used to obtain the current time as UTC. The type embodies an instantiation of duration and the class template time_point, and defines a static member function now() that returns the time.

A clock is monotonic if the value that is returned by a first call to now() is always less than or equal to the value that is returned by a subsequent call to now().

A clock is steady if it is monotonic and if the time between clock ticks is constant.

In this implementation, a system_clock is synonymous with a high_resolution_clock.

Public Typedefs

NameDescription
system_clock::durationA synonym for duration<rep, period>.
system_clock::periodA synonym for the type that is used to represent the tick period in the contained instantiation of duration.
system_clock::repA synonym for the type that is used to represent the number of clock ticks in the contained instantiation of duration.
system_clock::time_pointA synonym for time_point<Clock, duration>, where Clock is a synonym for either the clock type itself or another clock type that is based on the same epoch and has the same nested duration type.

Public Methods

NameDescription
system_clock::from_time_t MethodStatic. Returns a time_point that most closely approximates a specified time.
system_clock::now MethodStatic. Returns the current time.
system_clock::to_time_t MethodStatic. Returns a time_t object that most closely approximates a specified time_point.

Public Constants

NameDescription
system_clock::is_monotonic ConstantSpecifies whether the clock type is monotonic.
system_clock::is_steady ConstantSpecifies whether the clock type is steady.

Header: chrono

Namespace: std::chrono

Static method that returns a time_point that most closely approximates the time that is represented by Tm.

static time_point from_time_t(time_t Tm) noexcept;  

Parameters

Tm
A time_t object.

Static value that specifies whether the clock type is monotonic.

static const bool is_monotonic = false;  

Return Value

In this implementation, system_clock::is_monotonic always returns false.

Remarks

A clock is monotonic if the value that is returned by a first call to now() is always less than or equal to the value that is returned by a subsequent call to now().

Static value that specifies whether the clock type is steady.

static const bool is_steady = false;  

Return Value

In this implementation, system_clock::is_steady always returns false.

Remarks

A clock is steady if it is monotonic and if the time between clock ticks is constant.

Static method that returns the current time.

static time_point now() noexcept;  

Return Value

A time_point object that represents the current time.

Static method that returns a time_t that most closely approximates the time that is represented by Time.

static time_t to_time_t(const time_point& Time) noexcept;  

Parameters

Time
A time_point object.

Header Files Reference
<chrono>
steady_clock struct

Show: