Skip to content

Commit 20febbf

Browse files
authored
Merge pull request MicrosoftDocs#3675 from MicrosoftDocs/master
7/23 Publishing
2 parents fb4e8dd + 950e559 commit 20febbf

File tree

4 files changed

+224
-87
lines changed

4 files changed

+224
-87
lines changed

docs/standard-library/chrono.md

+82-77
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
description: "Learn more about: <chrono>"
3-
title: "<chrono>"
4-
ms.date: 06/16/2021
2+
description: "Learn more about: <chrono>"
3+
title: "<chrono>"
4+
ms.date: 07/01/2021
55
f1_keywords: ["<chrono>", "chrono/std::chrono::nanoseconds", "chrono/std::chrono::minutes", "chrono/std::chrono::seconds", "chrono/std::chrono::hours", "chrono/std::chrono::milliseconds", "chrono/std::chrono::microseconds"]
66
---
7+
78
# `<chrono>`
89

910
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
1617

1718
**Namespace:** `std`
1819

19-
## Members
20-
21-
### Classes
20+
## Classes
2221

2322
| Name | Description |
2423
|--|--|
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
4746

4847
|Name|Description|
4948
|-|-|
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.|
5755

58-
### Functions
56+
## Functions
5957

6058
| Name | Description |
6159
|--|--|
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
8482

8583
|Name|Description|
8684
|-|-|
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).
103101

104102
|Name|Description|
105103
|-|-|
@@ -110,14 +108,21 @@ For more information about ratio types that are used in the following typedefs,
110108
|`typedef duration<int, ratio<60>> minutes;`|Synonym for a `duration` type that has a tick period of 1 minute.|
111109
|`typedef duration<int, ratio<3600>> hours;`|Synonym for a `duration` type that has a tick period of 1 hour.|
112110

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
114119

115120
|Name|Description|
116121
|-|-|
117122
|`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. |
118123
|`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. |
119124

120-
### Literals
125+
## Literals
121126

122127
**(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.
123128

@@ -146,4 +151,4 @@ constexpr auto my_duration_unit = 108ms;
146151

147152
## See also
148153

149-
[Header Files Reference](../standard-library/cpp-standard-library-header-files.md)
154+
[Header Files Reference](cpp-standard-library-header-files.md)
+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
description: "Learn more about is_clock struct"
3+
title: "is_clock class"
4+
ms.date: 07/19/2021
5+
f1_keywords: ["chrono/std::is_clock"]
6+
helpviewer_keywords: ["std::chrono [C++], is_clock"]
7+
---
8+
9+
# `is_clock` structure
10+
11+
A type trait that determines whether the specified type meets the requirements to be a clock.
12+
13+
## Syntax
14+
15+
```cpp
16+
template<class T> struct is_clock; // c++ 20
17+
```
18+
19+
**Helper variable template**
20+
21+
```cpp
22+
template<class T> inline constexpr bool is_clock_v = is_clock<T>::value; // c++ 20
23+
```
24+
25+
### Parameters
26+
27+
*`T`*\
28+
The type to test.
29+
30+
## Members
31+
32+
|Name|Description|
33+
|----------|-----------------|
34+
| [`value`](#value) | Indicates whether `T` satisfies the requirements to be a clock. |
35+
| [`operator ()`](#op_parens) | Returns [`value`](#value). |
36+
| [`operator bool`](#op_bool) | Returns [`value`](#value). |
37+
38+
## Remarks
39+
40+
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.
45+
46+
## Example
47+
48+
```cpp
49+
#include <iostream>
50+
#include <chrono>
51+
52+
using namespace std::chrono;
53+
54+
int main()
55+
{
56+
is_clock<system_clock> ic;
57+
58+
std::cout << std::boolalpha << ic.value << ", " << ic() << ", " << (bool)ic;
59+
return 0;
60+
}
61+
```
62+
63+
```output
64+
true, true, true
65+
```
66+
67+
## Requirements
68+
69+
**Header:** \<`chrono`>
70+
71+
**Namespace:** `std`
72+
73+
**Compiler Option:** [`/std:c++latest`](../build/reference/std-specify-language-standard-version.md)
74+
75+
## Value
76+
77+
Get whether the specified type satisfies the requirements to be a clock.
78+
79+
```cpp
80+
static constexpr T value;
81+
```
82+
83+
### Return value
84+
85+
`true` if specified type meets the requirements to be a clock. Otherwise, `false`.
86+
87+
## <a name="op_parens"></a> `operator()`
88+
89+
```cpp
90+
constexpr value_type operator()() const noexcept
91+
```
92+
93+
Returns `value`, that is, whether the specified type meets the requirements to be a clock.
94+
95+
### Return value
96+
97+
`true` if specified type meets the requirements to be a clock. Otherwise, `false`.
98+
99+
## <a name="op_bool"></a> `operator bool`
100+
101+
```cpp
102+
constexpr operator value_type() const noexcept
103+
```
104+
105+
Returns `value`, that is, whether the specified type meets the requirements to be a clock.
106+
107+
### Return value
108+
109+
`true` if specified type meets the requirements to be a clock. Otherwise, `false`.
110+
111+
## See also
112+
113+
[`<chrono>`](chrono.md)\
114+
[Header Files Reference](cpp-standard-library-header-files.md)

docs/standard-library/toc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@
160160
href: ../standard-library/hhmmss-class.md
161161
- name: high_resolution_clock struct
162162
href: high-resolution-clock-struct.md
163+
- name: is_clock struct
164+
href: is-clock-struct.md
163165
- name: leap_second class
164166
href: ../standard-library/leap-second-class.md
165167
- name: leap_second_info struct

0 commit comments

Comments
 (0)