Title: Theory / Unimportant / CS / Programming / C++ / Manual / IV STL / 35 Time

Typ: duration<type, time_unit>
Meaning: Counting duration using type with time counted in time_unit
Page: 1010
Language: C++
Chapter: 35
Section: 2.1

Instruction: duration<type, time_unit>(n)
Page: 1010
Language: C++
Chapter: 35
Section: 2.1
Returns: represents n time_units
Assuming: n can be converted to type losslessly
Typ: duration<type, time_unit>

Instruction: d.count()
Page: 1010
Language: C++
Chapter: 35
Section: 2.1
Returns: The number of clock tick in duration d
Variables: duration<type, time_unit> d

Instruction: d1 + d2
Page: 1010
Language: C++
Context: Duration
Chapter: 35
Section: 2.1
Returns: Sum of their duration
Variables: duration<type1, time_unit> d1
duration<type2, time_unit> d2
Typ: duration<common_type<type1, type2>, time_unit>

Instruction: d + n
Page: 1010
Language: C++
Chapter: 35
Section: 2.1
Returns: duration<type, time_unit> of duration sum of d and n
Variables: duration<type, time_unit> d
type n

Instruction: duration_cast<type2>(d)
Page: 1010
Language: C++
Chapter: 35
Section: 2.1
Returns: duration, but in type D
Variables: duration<type, time_unit> d

Instruction: d1 operator@ d2
Page: 1010
Language: C++
Chapter: 35
Section: 2.1
Returns: converting d1 and d2 to common_type<type1, type2>, and apply @ on their value
Variables: duration<type1, time_unit> d1
duration<type2, time_unit> d2

Meaning: siN
Page: 1013
Language: C++
Chapter: 35
Section: 2.1
Variables: N an integer
Implementation: An implementation-defined signed integer type of at least N bits

Typ: time_point<Clock, Duration>
Meaning: A point in time, represented as duration
Page: 1013
Language: C++
Chapter: 35
Section: 2.2

Instruction: time_point<Clock, Duration> {}
Page: 1013
Language: C++
Chapter: 35
Section: 2.2
Returns: epoch

Instruction: tp.time_since_epoch()
Page: 1014
Language: C++
Chapter: 35
Section: 2.2
Returns: duration since epoch
Variables: time_point tp;

Page: 1014
Syntactic sugar: time_point {n}
Implementation: time_point{} + n
Language: C++
Section: 2.2
Variables: n a number
Chapter: 35

Instruction: d1 operator@ d2
Page: 1014
Language: C++
Chapter: 35
Section: 2.2
Returns: Convert to common_type<type1, type2> and compare their value
Variables: time_point<type1, clock> d1
time_point<type2, clock> d2

Typ: system_clock
Meaning: wall clock time
Page: 1015
Language: C++
Chapter: 35
Section: 2.3

Instruction: now()
Page: 1015
Language: C++
Chapter: 35
Section: 2.3
Returns: Time_point of right now

Instruction: c.is_steady()
Page: 1015
Language: C++
Chapter: 35
Section: 2.3
Returns: Is this clock type steady?
Variables: Clock c;

Instruction: to_time_t(tp)
Page: 1015
Language: C++
Chapter: 35
Section: 2.3
Returns: the time_t for tp
Variables: time_point tp

Instruction: from_þime_t(t)
Page: 1015
Language: C++
Chapter: 35
Section: 2.3
Returns: the time_point for t
Variables: time_t t

Name: A steady clock
Definition: A clock  that never goes back in time
Page: 1015
Chapter: 35
Section: 2.3

Typ: system_clock
Meaning: The system’s real-time clock
Page: 1015
Language: C++
Chapter: 35
Section: 2.3

Typ: steady_clock
Meaning: A clock where time moves steadily forward;
that is, time does not go backward
and the time between clock ticks is constant
Page: 1015
Language: C++
Chapter: 35
Section: 2.3

Typ: high_resolution_clock
Meaning: A clock with the shortest time increment on a system
Page: 1015
Language: C++
Chapter: 35
Section: 2.3

Typ: ratio
Meaning: compile-time rational arithmetic
Page: 1017
Language: C++
Chapter: 35
Section: 3
Intuition: Allow to compute precision of type of values at compile time

Instruction: ratio_add/subtract/multiply/divide<x, y>
Page: 1017
Language: C++
Chapter: 35
Section: 3
Returns: the sum, minus, product, quotient of x and y
Variables: ratio x, y

Instruction: ratio_equal/not_equal/less/less_equal/greater/greater_equal<x, y>
Page: 1017
Language: C++
Chapter: 35
Section: 3
Returns: x ==/!=/</<=/>/>= y
Variables: ratio x, y

Instruction: ratio<n,m>
Page: 1017
Language: C++
Chapter: 35
Section: 3
Returns: represents the fraction \(\frac nm\)