From Jason Turner

[time.clock.system]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpv5b_fe10/{from.md → to.md} +82 -7
tmp/tmpv5b_fe10/{from.md → to.md} RENAMED
@@ -1,34 +1,49 @@
1
- #### Class `system_clock` <a id="time.clock.system">[[time.clock.system]]</a>
2
 
3
- Objects of class `system_clock` represent wall clock time from the
4
- system-wide realtime clock.
5
 
6
  ``` cpp
 
7
  class system_clock {
8
  public:
9
  using rep = see below;
10
  using period = ratio<unspecified, unspecified{}>;
11
  using duration = chrono::duration<rep, period>;
12
  using time_point = chrono::time_point<system_clock>;
13
  static constexpr bool is_steady = unspecified;
14
 
15
  static time_point now() noexcept;
16
 
17
- // Map to C API
18
  static time_t to_time_t (const time_point& t) noexcept;
19
  static time_point from_time_t(time_t t) noexcept;
20
  };
 
21
  ```
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  ``` cpp
24
  using system_clock::rep = unspecified;
25
  ```
26
 
27
- *Requires:*
28
- `system_clock::duration::min() < system_clock::duration::zero()` shall
29
- be `true`.
30
 
31
  [*Note 1*: This implies that `rep` is a signed type. — *end note*]
32
 
33
  ``` cpp
34
  static time_t to_time_t(const time_point& t) noexcept;
@@ -46,5 +61,65 @@ static time_point from_time_t(time_t t) noexcept;
46
  *Returns:* A `time_point` object that represents the same point in time
47
  as `t` when both values are restricted to the coarser of the precisions
48
  of `time_t` and `time_point`. It is *implementation-defined* whether
49
  values are rounded or truncated to the required precision.
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Class `system_clock` <a id="time.clock.system">[[time.clock.system]]</a>
2
 
3
+ #### Overview <a id="time.clock.system.overview">[[time.clock.system.overview]]</a>
 
4
 
5
  ``` cpp
6
+ namespace std::chrono {
7
  class system_clock {
8
  public:
9
  using rep = see below;
10
  using period = ratio<unspecified, unspecified{}>;
11
  using duration = chrono::duration<rep, period>;
12
  using time_point = chrono::time_point<system_clock>;
13
  static constexpr bool is_steady = unspecified;
14
 
15
  static time_point now() noexcept;
16
 
17
+ // mapping to/from C type time_t
18
  static time_t to_time_t (const time_point& t) noexcept;
19
  static time_point from_time_t(time_t t) noexcept;
20
  };
21
+ }
22
  ```
23
 
24
+ Objects of type `system_clock` represent wall clock time from the
25
+ system-wide realtime clock. Objects of type `sys_time<Duration>` measure
26
+ time since 1970-01-01 00:00:00 UTC excluding leap seconds. This measure
27
+ is commonly referred to as *Unix time*. This measure facilitates an
28
+ efficient mapping between `sys_time` and calendar types [[time.cal]].
29
+
30
+ [*Example 1*:
31
+ `sys_seconds{sys_days{1970y/January/1}}.time_since_epoch()` is `0s`.
32
+ `sys_seconds{sys_days{2000y/January/1}}.time_since_epoch()` is
33
+ `946'684'800s`, which is `10'957 * 86'400s`.
34
+ — *end example*]
35
+
36
+ #### Members <a id="time.clock.system.members">[[time.clock.system.members]]</a>
37
+
38
  ``` cpp
39
  using system_clock::rep = unspecified;
40
  ```
41
 
42
+ *Constraints:*
43
+ `system_clock::duration::min() < system_clock::duration::zero()` is
44
+ `true`.
45
 
46
  [*Note 1*: This implies that `rep` is a signed type. — *end note*]
47
 
48
  ``` cpp
49
  static time_t to_time_t(const time_point& t) noexcept;
 
61
  *Returns:* A `time_point` object that represents the same point in time
62
  as `t` when both values are restricted to the coarser of the precisions
63
  of `time_t` and `time_point`. It is *implementation-defined* whether
64
  values are rounded or truncated to the required precision.
65
 
66
+ #### Non-member functions <a id="time.clock.system.nonmembers">[[time.clock.system.nonmembers]]</a>
67
+
68
+ ``` cpp
69
+ template<class charT, class traits, class Duration>
70
+ basic_ostream<charT, traits>&
71
+ operator<<(basic_ostream<charT, traits>& os, const sys_time<Duration>& tp);
72
+ ```
73
+
74
+ *Constraints:* `treat_as_floating_point_v<typename Duration::rep>` is
75
+ `false`, and `Duration{1} < days{1}` is `true`.
76
+
77
+ *Effects:* Equivalent to:
78
+
79
+ ``` cpp
80
+ auto const dp = floor<days>(tp);
81
+ return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{} {}"),
82
+ year_month_day{dp}, hh_mm_ss{tp-dp});
83
+ ```
84
+
85
+ [*Example 1*:
86
+
87
+ ``` cpp
88
+ cout << sys_seconds{0s} << '\n'; // 1970-01-01 00:00:00
89
+ cout << sys_seconds{946'684'800s} << '\n'; // 2000-01-01 00:00:00
90
+ cout << sys_seconds{946'688'523s} << '\n'; // 2000-01-01 01:02:03
91
+ ```
92
+
93
+ — *end example*]
94
+
95
+ ``` cpp
96
+ template<class charT, class traits>
97
+ basic_ostream<charT, traits>&
98
+ operator<<(basic_ostream<charT, traits>& os, const sys_days& dp);
99
+ ```
100
+
101
+ *Effects:* `os << year_month_day{dp}`.
102
+
103
+ *Returns:* `os`.
104
+
105
+ ``` cpp
106
+ template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
107
+ basic_istream<charT, traits>&
108
+ from_stream(basic_istream<charT, traits>& is, const charT* fmt,
109
+ sys_time<Duration>& tp, basic_string<charT, traits, Alloc>* abbrev = nullptr,
110
+ minutes* offset = nullptr);
111
+ ```
112
+
113
+ *Effects:* Attempts to parse the input stream `is` into the `sys_time`
114
+ `tp` using the format flags given in the NTCTS `fmt` as specified in
115
+ [[time.parse]]. If the parse fails to decode a valid date,
116
+ `is.setstate(ios_base::failbit)` is called and `tp` is not modified. If
117
+ `%Z` is used and successfully parsed, that value will be assigned to
118
+ `*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
119
+ used and successfully parsed, that value will be assigned to `*offset`
120
+ if `offset` is non-null. Additionally, the parsed offset will be
121
+ subtracted from the successfully parsed timestamp prior to assigning
122
+ that difference to `tp`.
123
+
124
+ *Returns:* `is`.
125
+