Compartilhar via


system_clock Structure

 

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.

Syntax

struct system_clock;  

Remarks

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.

Members

Public Typedefs

Name Description
system_clock::duration A synonym for duration<rep, period>.
system_clock::period A synonym for the type that is used to represent the tick period in the contained instantiation of duration.
system_clock::rep A synonym for the type that is used to represent the number of clock ticks in the contained instantiation of duration.
system_clock::time_point A 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

Name Description
system_clock::from_time_t Method Static. Returns a time_point that most closely approximates a specified time.
system_clock::now Method Static. Returns the current time.
system_clock::to_time_t Method Static. Returns a time_t object that most closely approximates a specified time_point.

Public Constants

Name Description
system_clock::is_monotonic Constant Specifies whether the clock type is monotonic.
system_clock::is_steady Constant Specifies whether the clock type is steady.

Requirements

Header: chrono

Namespace: std::chrono

system_clock::from_time_t Method

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.

system_clock::is_monotonic Constant

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().

system_clock::is_steady Constant

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.

system_clock::now Method

Static method that returns the current time.

static time_point now() noexcept;  

Return Value

A time_point object that represents the current time.

system_clock::to_time_t Method

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.

See Also

Header Files Reference
<chrono>
steady_clock struct