You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Include the standard header `<chrono>` to define classes and functions that represent and manipulate time durations and time instants.
@@ -16,90 +17,87 @@ Beginning in Visual Studio 2015, the implementation of `steady_clock` has change
16
17
17
18
**Namespace:**`std`
18
19
19
-
## Members
20
-
21
-
### Classes
20
+
## Classes
22
21
23
22
| Name | Description |
24
23
|--|--|
25
-
|[`day` class](../standard-library/day-class.md)| A day of the month. For example, the 25th day of the month. |
26
-
|[`duration` class](../standard-library/duration-class.md)| A time interval. |
27
-
|[`hh_mm_ss` class](../standard-library/hhmmss-class.md)| Splits a [`duration`](duration-class.md) into hours:minutes:seconds. |
28
-
|[`leap_second` class](../standard-library/leap-second-class.md)| A date and a value for an inserted leap second. |
29
-
|[`month` class](../standard-library/month-class.md)| A month of a year. For example, July. |
30
-
|[`month_day` class](../standard-library/month-day-class.md)| A specific day of a specific month. For example, July 30th. |
31
-
|[`month_day_last` class](../standard-library/month-day-last-class.md)| The last day of a month. |
32
-
|[`month_weekday` class](../standard-library/month-day-last-class.md)| The nth weekday of a specific month. |
33
-
|[`month_weekday_last` class](../standard-library/month-weekday-last-class.md)| The nth weekday of a specific month. |
34
-
|[`time_point` class](../standard-library/time-point-class.md)| A point in time. |
35
-
|[`time_zone` class](../standard-library/time-point-class.md)| All time zone transitions for a specific geographic area. |
36
-
|[`weekday` class](../standard-library/weekday-class.md)| A day of the week. |
37
-
|[`weekday_last` class](../standard-library/weekdaylast-class.md)| The last weekday of a month. |
38
-
|[`weekday_indexed` class](../standard-library/weekdayindexed-class.md)| Combines a day of the week with an index that represents the weekday of the month. |
39
-
|[`year` class](../standard-library/year-class.md)| A year in the [Gregorian calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar).|
40
-
|[`year_month` class](../standard-library/year-month-class.md)| A year and month. The day isn't specified.|
41
-
|[`year_month_day` class](../standard-library/year-month-day-class.md)| A year, month, and day.|
42
-
|[`year_month_day_last` class](../standard-library/year-month-day-last-class.md)| The last day of a specific month and year. |
43
-
|[`year_month_weekday` class](../standard-library/year-month-weekday-class.md)| A specific year, month, and nth weekday of the month. |
44
-
|[`year_month_weekday_last` class](../standard-library/year-month-weekday-last-class.md)| A specific year, month, and last weekday of the month. |
45
-
46
-
###Structs
24
+
|[`day` class](day-class.md)| A day of the month. For example, the 25th day of the month. |
25
+
|[`duration` class](duration-class.md)| A time interval. |
26
+
|[`hh_mm_ss` class](hhmmss-class.md)| Splits a [`duration`](duration-class.md) into hours:minutes:seconds. |
27
+
|[`leap_second` class](leap-second-class.md)| A date and a value for an inserted leap second. |
28
+
|[`month` class](month-class.md)| A month of a year. For example, July. |
29
+
|[`month_day` class](month-day-class.md)| A specific day of a specific month. For example, July 30th. |
30
+
|[`month_day_last` class](month-day-last-class.md)| The last day of a month. |
31
+
|[`month_weekday` class](month-day-last-class.md)| The nth weekday of a specific month. |
32
+
|[`month_weekday_last` class](month-weekday-last-class.md)| The nth weekday of a specific month. |
33
+
|[`time_point` class](time-point-class.md)| A point in time. |
34
+
|[`time_zone` class](time-point-class.md)| All time zone transitions for a specific geographic area. |
35
+
|[`weekday` class](weekday-class.md)| A day of the week. |
36
+
|[`weekday_last` class](weekdaylast-class.md)| The last weekday of a month. |
37
+
|[`weekday_indexed` class](weekdayindexed-class.md)| Combines a day of the week with an index that represents the weekday of the month. |
38
+
|[`year` class](year-class.md)| A year in the [Gregorian calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar).|
39
+
|[`year_month` class](year-month-class.md)| A year and month. The day isn't specified.|
40
+
|[`year_month_day` class](year-month-day-class.md)| A year, month, and day.|
41
+
|[`year_month_day_last` class](year-month-day-last-class.md)| The last day of a specific month and year. |
42
+
|[`year_month_weekday` class](year-month-weekday-class.md)| A specific year, month, and nth weekday of the month. |
43
+
|[`year_month_weekday_last` class](year-month-weekday-last-class.md)| A specific year, month, and last weekday of the month. |
44
+
45
+
## Structs
47
46
48
47
|Name|Description|
49
48
|-|-|
50
-
|[`common_type` struct](../standard-library/common-type-structure.md)|Describes specializations of class template [`common_type`](../standard-library/common-type-class.md) for instantiations of `duration` and `time_point`.|
51
-
|[`duration_values` struct](../standard-library/duration-values-structure.md)|Provides specific values for the `duration` template parameter `Rep`.|
52
-
|[`high_resolution_clock` struct](../standard-library/high-resolution-clock-struct.md)| A clock with a nanosecond tick period. |
53
-
|[`leap_second_info` struct](../standard-library/leap-second-info-struct.md)| The data returned by [`get_leap_second_info`](chrono-functions.md#std-chrono-get-leap-second-info). |
54
-
|[`steady_clock` struct](../standard-library/steady-clock-struct.md)|A `steady` clock. Preferred for measuring time intervals. |
55
-
|[`system_clock` struct](../standard-library/system-clock-structure.md)|A *`clock type`* that is based on the real-time clock of the system.|
56
-
|[`treat_as_floating_point` struct](../standard-library/treat-as-floating-point-structure.md)|Specifies whether a type can be treated as a floating-point type.|
49
+
|[`common_type` struct](common-type-structure.md)|Describes specializations of class template [`common_type`](common-type-class.md) for instantiations of `duration` and `time_point`.|
50
+
|[`duration_values` struct](duration-values-structure.md)|Provides specific values for the `duration` template parameter `Rep`.|
51
+
|[`high_resolution_clock` struct](high-resolution-clock-struct.md)| A clock with a nanosecond tick period. |
52
+
|[`leap_second_info` struct](leap-second-info-struct.md)| The data returned by [`get_leap_second_info`](chrono-functions.md#std-chrono-get-leap-second-info). |
53
+
|[`steady_clock` struct](steady-clock-struct.md)|A `steady` clock. Preferred for measuring time intervals. |
54
+
|[`system_clock` struct](system-clock-structure.md)|A *`clock type`* that is based on the real-time clock of the system.|
57
55
58
-
###Functions
56
+
## Functions
59
57
60
58
| Name | Description |
61
59
|--|--|
62
-
|[`ceil(duration)`](./chrono-functions.md#std-chrono-ceil-duration)| Returns the `ceil` of a `duration` object as a specified type. |
63
-
|[`ceil(time_point)`](./chrono-functions.md#std-chrono-ceil-time-point)| Returns the `ceil` of a `time_point` object as a specified type. |
64
-
|[`current_zone`](./chrono-functions.md#std-chrono-current-zone)| Gets the current time zone. |
65
-
|[`duration_cast`](./chrono-functions.md#std-chrono-duration-cast)| Casts a `duration` object to a specified type. |
66
-
|[`floor(duration)`](./chrono-functions.md#std-chrono-floor-duration)| Returns the `floor` of a `duration` object as a specified type. |
67
-
|[`floor(time_point)`](./chrono-functions.md#std-chrono-floor-time-point)| Returns the `floor` of a `time_point` object as a specified type. |
68
-
|[`from_stream()`](./chrono-functions.md#std-chrono-from-stream)| Parse the input stream into one of the `std::chrono` time or interval types such as `day`, `month`, `weekday`, `year`, and so on, using the specified format. |
69
-
|[`get_leap_second_info`](./chrono-functions.md#std-chrono-get-leap-second-info)| Gets a [`leap_second_info` struct](../standard-library/leap-second-info-struct.md). |
70
-
|[`get_tzdb_list`](./chrono-functions.md#std-chrono-get-tzdb-list)| Gets the list of time zone database entries. |
71
-
|[`get_tzdb`](./chrono-functions.md#std-chrono-get-tzdb)| Gets the first time zone database entry. |
72
-
|[`is_am`](./chrono-functions.md#std-chrono-is-am)| Whether an `hours` object is AM. |
73
-
|[`is_pm`](./chrono-functions.md#std-chrono-is-pm)| Whether an `hours` object is PM. |
74
-
|[`locate_zone`](./chrono-functions.md#std-chrono-locate-zone)| Gets a specified time zone. |
75
-
|[`make12`](./chrono-functions.md#std-chrono-make12)| Returns an `hours` in 12-hour form. |
76
-
|[`make24`](./chrono-functions.md#std-chrono-make24)| Returns an `hours` in 24-hour form. |
77
-
|[`reload_tzdb`](./chrono-functions.md#std-chrono-reload-tzdb)| Gets an updated time zone database entry. |
78
-
|[`remote_version`](./chrono-functions.md#std-chrono-remote-version)| Checks for an updated time zone database entry. |
79
-
|[`round(duration)`](./chrono-functions.md#std-chrono-round-duration)| Returns a `duration` object rounded as a specified type. |
80
-
|[`round(time_point)`](./chrono-functions.md#std-chrono-round-time-point)| Returns a `time_point` object rounded as a specified type. |
81
-
|[`time_point_cast`](./chrono-functions.md#std-chrono-time-point-cast)| Casts a `time_point` object to a specified type. |
82
-
83
-
###Operators
60
+
|[`ceil(duration)`](chrono-functions.md#std-chrono-ceil-duration)| Returns the `ceil` of a `duration` object as a specified type. |
61
+
|[`ceil(time_point)`](chrono-functions.md#std-chrono-ceil-time-point)| Returns the `ceil` of a `time_point` object as a specified type. |
62
+
|[`current_zone`](chrono-functions.md#std-chrono-current-zone)| Gets the current time zone. |
63
+
|[`duration_cast`](chrono-functions.md#std-chrono-duration-cast)| Casts a `duration` object to a specified type. |
64
+
|[`floor(duration)`](chrono-functions.md#std-chrono-floor-duration)| Returns the `floor` of a `duration` object as a specified type. |
65
+
|[`floor(time_point)`](chrono-functions.md#std-chrono-floor-time-point)| Returns the `floor` of a `time_point` object as a specified type. |
66
+
|[`from_stream()`](chrono-functions.md#std-chrono-from-stream)| Parse the input stream into one of the `std::chrono` time or interval types such as `day`, `month`, `weekday`, `year`, and so on, using the specified format. |
67
+
|[`get_leap_second_info`](chrono-functions.md#std-chrono-get-leap-second-info)| Gets a [`leap_second_info` struct](leap-second-info-struct.md). |
68
+
|[`get_tzdb_list`](chrono-functions.md#std-chrono-get-tzdb-list)| Gets the list of time zone database entries. |
69
+
|[`get_tzdb`](chrono-functions.md#std-chrono-get-tzdb)| Gets the first time zone database entry. |
70
+
|[`is_am`](chrono-functions.md#std-chrono-is-am)| Whether an `hours` object is AM. |
71
+
|[`is_pm`](chrono-functions.md#std-chrono-is-pm)| Whether an `hours` object is PM. |
72
+
|[`locate_zone`](chrono-functions.md#std-chrono-locate-zone)| Gets a specified time zone. |
73
+
|[`make12`](chrono-functions.md#std-chrono-make12)| Returns an `hours` in 12-hour form. |
74
+
|[`make24`](chrono-functions.md#std-chrono-make24)| Returns an `hours` in 24-hour form. |
75
+
|[`reload_tzdb`](chrono-functions.md#std-chrono-reload-tzdb)| Gets an updated time zone database entry. |
76
+
|[`remote_version`](chrono-functions.md#std-chrono-remote-version)| Checks for an updated time zone database entry. |
77
+
|[`round(duration)`](chrono-functions.md#std-chrono-round-duration)| Returns a `duration` object rounded as a specified type. |
78
+
|[`round(time_point)`](chrono-functions.md#std-chrono-round-time-point)| Returns a `time_point` object rounded as a specified type. |
79
+
|[`time_point_cast`](chrono-functions.md#std-chrono-time-point-cast)| Casts a `time_point` object to a specified type. |
80
+
81
+
## Operators
84
82
85
83
|Name|Description|
86
84
|-|-|
87
-
|[`operator-`](../standard-library/chrono-operators.md#op_minus)|Subtract or negate various <chrono> objects.|
88
-
|[`operator!=`](../standard-library/chrono-operators.md#op_neq)|Inequality operator that is used with various <chrono> objects.|
89
-
|[`operator modulo`](../standard-library/chrono-operators.md#op_modulo)|Operator for modulo operations on `duration` objects.|
90
-
|[`operator*`](../standard-library/chrono-operators.md#op_star)|Multiplication operator for `duration` objects.|
91
-
|[`operator/`](../standard-library/chrono-operators.md#op_div)|Division operator for `duration` objects.|
92
-
|[`operator/`](../standard-library/chrono-operators.md#op_/)|Provides syntax to create calendar dates.|
93
-
|[`operator+`](../standard-library/chrono-operators.md#op_add)|Add to various <chrono> objects.|
94
-
|[`operator<`](../standard-library/chrono-operators.md#op_lt)|Determines whether various <chrono> objects are less than another.|
95
-
|[`operator<=`](../standard-library/chrono-operators.md#op_lt_eq)|Determines whether various <chrono> objects are less than or equal to another.|
96
-
|[`operator==`](../standard-library/chrono-operators.md#op_eq_eq)|Determines whether various <chrono> objects are equal to each other.|
97
-
|[`operator>`](../standard-library/chrono-operators.md#op_gt)|Determines whether various <chrono> objects are greater than another.|
98
-
|[`operator>=`](../standard-library/chrono-operators.md#op_gt_eq)|Determines whether various <chrono> objects are greater than or equal to another.|
99
-
100
-
###Typedefs (Predefined Duration Types)
101
-
102
-
For more information about ratio types that are used in the following typedefs, see [`<ratio>`](../standard-library/ratio.md).
85
+
|[`operator-`](chrono-operators.md#op_minus)|Subtract or negate various <chrono> objects.|
86
+
|[`operator!=`](chrono-operators.md#op_neq)|Inequality operator that is used with various <chrono> objects.|
87
+
|[`operator modulo`](chrono-operators.md#op_modulo)|Operator for modulo operations on `duration` objects.|
88
+
|[`operator*`](chrono-operators.md#op_star)|Multiplication operator for `duration` objects.|
89
+
|[`operator/`](chrono-operators.md#op_div)|Division operator for `duration` objects.|
90
+
|[`operator/`](chrono-operators.md#op_/)|Provides syntax to create calendar dates.|
91
+
|[`operator+`](chrono-operators.md#op_add)|Add to various <chrono> objects.|
92
+
|[`operator<`](chrono-operators.md#op_lt)|Determines whether various <chrono> objects are less than another.|
93
+
|[`operator<=`](chrono-operators.md#op_lt_eq)|Determines whether various <chrono> objects are less than or equal to another.|
94
+
|[`operator==`](chrono-operators.md#op_eq_eq)|Determines whether various <chrono> objects are equal to each other.|
95
+
|[`operator>`](chrono-operators.md#op_gt)|Determines whether various <chrono> objects are greater than another.|
96
+
|[`operator>=`](chrono-operators.md#op_gt_eq)|Determines whether various <chrono> objects are greater than or equal to another.|
97
+
98
+
## Typedefs (Predefined duration types)
99
+
100
+
For more information about ratio types that are used in the following typedefs, see [`<ratio>`](ratio.md).
103
101
104
102
|Name|Description|
105
103
|-|-|
@@ -110,14 +108,21 @@ For more information about ratio types that are used in the following typedefs,
110
108
|`typedef duration<int, ratio<60>> minutes;`|Synonym for a `duration` type that has a tick period of 1 minute.|
111
109
|`typedef duration<int, ratio<3600>> hours;`|Synonym for a `duration` type that has a tick period of 1 hour.|
112
110
113
-
### Alias declarations
111
+
## Type traits
112
+
113
+
|Name|Description|
114
+
|-|-|
115
+
|[is_clock](is-clock-struct.md)| See if a type is a clock. |
116
+
|[treat_as_floating_point](treat-as-floating-point-structure.md)| See if a `duration` can be converted to another `duration` that has a different tick period.|
117
+
118
+
## Alias declarations
114
119
115
120
|Name|Description|
116
121
|-|-|
117
122
|`using local_days = local_time<days>;`| A count of days, represented by a [`time_point`](time-point-class.md) that is not associated with any time zone. |
118
123
|`using sys_days = sys_time<days>;`| A count of days, represented by a `time_point` that is associated with a [`system_clock`](system-clock-structure.md), which has a 1/1/1970 epoch. |
119
124
120
-
###Literals
125
+
## Literals
121
126
122
127
**(C++11)** The `<chrono>` header defines the following [user-defined literals](../cpp/user-defined-literals-cpp.md) that you can use for greater convenience, type-safety, and maintainability of your code. These literals are defined in the `literals::chrono_literals` inline namespace and are in scope when `std::chrono` is in scope.
123
128
@@ -146,4 +151,4 @@ constexpr auto my_duration_unit = 108ms;
A clock has a `rep`, `period`, `duration`, `time_point`, `is_steady`, and a `now()` function.
41
+
42
+
For more details about the requirements to be a C++17 clock, see [Cpp17Clock requirements](https://eel.is/c++draft/tab:time.clock).
43
+
44
+
The following code works because `is_clock`, derives from `Cpp17UnaryTypeTrait`, which derives from `integral_constant`. This is where `value_type`, which is a `bool`, and `type`, which is a `std::integral_constant<bool, value>` come from.
0 commit comments