Skip to content

Repo sync for protected CLA branch #3225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/standard-library/chrono-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
description: "Learn more about: <chrono> functions"
title: "<chrono> functions"
ms.date: 6/16/2021
f1_keywords: ["chrono/std::duration_cast", "chrono/std::time_point_cast", "chrono/std::from_stream", "chrono/std::chrono::duration_cast", "chrono/std::chrono::time_point_cast", "chrono/std::chrono::from_stream", "chrono/std::chrono::floor", "chrono/std::chrono::ceil", "chrono/std::chrono::round", "chrono/std::chrono::is_am", "chrono/std::chrono::is_pm", "chrono/std::chrono::make12", "chrono/std::chrono::make24", "chrono/std::chrono::get_leap_second_info", "chrono/std::chrono::get_tzdb", "chrono/std::chrono::get_tzdb_list", "chrono/std::chrono::locate_zone", "chrono/std::chrono::current_zone", "chrono/std::chrono::reload_tzdb", "chrono/std::chrono::remote_version"]
f1_keywords: ["chrono/std::duration_cast", "chrono/std::time_point_cast", "chrono/std::chrono::duration_cast", "chrono/std::chrono::time_point_cast", "chrono/std::chrono::from_stream", "chrono/std::chrono::floor", "chrono/std::chrono::ceil", "chrono/std::chrono::round", "chrono/std::chrono::is_am", "chrono/std::chrono::is_pm", "chrono/std::chrono::make12", "chrono/std::chrono::make24", "chrono/std::chrono::get_leap_second_info", "chrono/std::chrono::get_tzdb", "chrono/std::chrono::get_tzdb_list", "chrono/std::chrono::locate_zone", "chrono/std::chrono::current_zone", "chrono/std::chrono::reload_tzdb", "chrono/std::chrono::remote_version"]
helpviewer_keywords: ["std::duration_cast function", "std::time_point_cast function", "std::chrono::duration_cast function", "std::chrono::time_point_cast function", "std::chrono::from_stream function", "std::chrono::floor function", "std::chrono::ceil function", "std::chrono::round function", "std::chrono::is_am function", "std::chrono::is_pm function", "std::chrono::make12 function", "std::chrono::make24 function", "std::chrono::get_leap_second_info function", "std::chrono::get_tzdb function", "std::chrono::get_tzdb_list function", "std::chrono::locate_zone function", "std::chrono::current_zone function", "std::chrono::reload_tzdb function", "std::chrono::remote_version function"]
---

Expand Down
394 changes: 303 additions & 91 deletions docs/standard-library/chrono-operators.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/standard-library/chrono.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ Beginning in Visual Studio 2015, the implementation of `steady_clock` has change
| [`year` class](../standard-library/year-class.md) | A year in the [Gregorian calendar](https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar).|
| [`year_month` class](../standard-library/year-month-class.md) | A year and month. The day isn't specified.|
| [`year_month_day` class](../standard-library/year-month-day-class.md) | A year, month, and day.|
| [`year_month_day_last` class](../standard-library/year-month-day-last-class.md) | The last day of a specific month and year. |
| [`year_month_weekday` class](../standard-library/year-month-weekday-class.md) | A specific year, month, and nth weekday of the month. |
| [`year_month_weekday_last` class](../standard-library/year-month-weekday-last-class.md) | A specific year, month, and last weekday of the month. |

### Structs

Expand Down
6 changes: 3 additions & 3 deletions docs/standard-library/month-class.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: month Class"
title: "month class"
ms.date: "04/26/2021"
ms.date: "6/25/2021"
f1_keywords: ["chrono/std::chrono::month", "chrono/std::chrono::month::January", "chrono/std::chrono::month::February", "chrono/std::chrono::month::March","chrono/std::chrono::month::April","chrono/std::chrono::month::May","chrono/std::chrono::month::June","chrono/std::chrono::month::July","chrono/std::chrono::month::August","chrono/std::chrono::month::September","chrono/std::chrono::month::October","chrono/std::chrono::month::November","chrono/std::chrono::month::December","chrono/std::chrono::month::operator++", "chrono/std::chrono::month::operator--", "chrono/std::chrono::month::operator unsigned", "chrono/std::chrono::month::ok"]
helpviewer_keywords: ["std::chrono [C++], month"]
---
Expand Down Expand Up @@ -107,7 +107,7 @@ using namespace std::chrono;

int main()
{
month m{1};
month m{January};

std::cout << m << " " << ++m << "\n"; // constexpr month& operator++() noexcept
std::cout << m << " " << m++ << "\n"; // constexpr month operator++(int) noexcept
Expand Down Expand Up @@ -153,7 +153,7 @@ using namespace std::chrono;

int main()
{
std::chrono::month m{5};
month m{May};

cout << m << " " << --m << "\n"; // constexpr month& operator++() noexcept
cout << m << " " << m-- << "\n"; // constexpr month operator++(int) noexcept
Expand Down
14 changes: 6 additions & 8 deletions docs/standard-library/month-day-class.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: month_day Class"
title: "month_day class"
ms.date: "6/4/2021"
ms.date: "6/25/2021"
f1_keywords: ["chrono/std::chrono::month_day", "chrono/std::chrono::month_day::day", "chrono/std::chrono::month_day::month", "chrono/std::chrono::month_day::ok"]
helpviewer_keywords: ["std::chrono [C++], month_day"]
---
Expand Down Expand Up @@ -75,19 +75,17 @@ using namespace std::chrono;
int main()
{
month m(7);
day d(30);
month_day md(m, d);
month_day md(30d/July);
month_day md2 = July/30; // another way to construct a month_day
month_day md2 = July/30; // a convenient way to construct a month_day
std::cout << md << ' ' << md2;
std::cout << md << '\n' << md2;
return 0;
}
```

```output
Jul/30 Jul/30
Jul/30
Jul/30
```

## <a name="day"></a> `day`
Expand Down
14 changes: 9 additions & 5 deletions docs/standard-library/month-day-last-class.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: month_day_last Class"
title: "month_day_last class"
ms.date: "06/04/2021"
ms.date: "06/25/2021"
f1_keywords: ["chrono/std::chrono::month_day_last", "chrono/std::chrono::month_day_last::month", "chrono/std::chrono::month_day_last::ok"]
helpviewer_keywords: ["std::chrono [C++], month_day_last"]
---
Expand Down Expand Up @@ -63,13 +63,17 @@ using namespace std::chrono;
int main()
{
month_day_last mdl = month_day_last(month(10));
// a convenient way to create a month_day_last
month_day_last mdl2 {October / last };
month_day_last mdl{ October / last };
std::cout << mdl;
return 0;
}
```

```output
Oct/last
```

## <a name="month"></a> `month`

Return the month value.
Expand Down
9 changes: 4 additions & 5 deletions docs/standard-library/month-weekday-class.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: month_weekday Class"
title: "month_weekday class"
ms.date: "06/4/2021"
ms.date: "06/25/2021"
f1_keywords: ["chrono/std::chrono::month_weekday", "chrono/std::chrono::month_weekday::weekday", "chrono/std::chrono::month_weekday::month", "chrono/std::chrono::month_weekday::ok", "chrono/std::chrono::month_weekday::weekday_indexed"]
helpviewer_keywords: ["std::chrono [C++], month_weekday"]
---
Expand Down Expand Up @@ -72,14 +72,13 @@ using namespace std::chrono;
int main()
{
constexpr auto wdi = weekday_indexed(Monday, 1);
constexpr auto month = July;
month_weekday mw(month, wdi);
month_weekday mw{ July/Monday[1] };
std::cout << mw << '\n';
// A convenient way to create a month_weekday
// Another way to create a month_weekday
month_weekday mw2 = February / Tuesday[3];
std::cout << mw2;
return 0;
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/standard-library/month-weekday-last-class.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: month_weekday_last Class"
title: "month_weekday_last class"
ms.date: "5/21/2021"
ms.date: "6/25/2021"
f1_keywords: ["chrono/std::chrono::month_weekday_last", "chrono/std::chrono::month_weekday_last::ok", "std::chrono::month_weekday_last::month_weekday_last", "chrono/std::chrono::month_weekday_last::ok", "chrono/std::chrono::month_weekday_last::month"]
helpviewer_keywords: ["std::chrono [C++], month_weekday_last"]
---
Expand Down Expand Up @@ -71,7 +71,7 @@ using namespace std::chrono;

int main()
{
constexpr auto mwdl = January/Monday[last]; // wdl is the last Monday of January of an unspecified year
constexpr auto mwdl{ January / Monday[last] }; // wdl is the last Monday of January of an unspecified year
std::cout << mwdl << "\n";

const auto theMonth = August;
Expand Down
6 changes: 6 additions & 0 deletions docs/standard-library/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@
href: year-month-class.md
- name: year_month_day class
href: year-month-day-class.md
- name: year_month_day_last class
href: year-month-day-last-class.md
- name: year_month_weekday class
href: year-month-weekday-class.md
- name: year_month_weekday_last class
href: year-month-weekday-last-class.md
- name: <cinttypes>
href: ../standard-library/cinttypes.md
- name: <ciso646>
Expand Down
41 changes: 31 additions & 10 deletions docs/standard-library/weekday-class.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: weekday Class"
title: "weekday class"
ms.date: "04/28/2021"
ms.date: "6/25/2021"
f1_keywords: ["chrono/std::chrono::weekday", "chrono/std::chrono::weekday::January", "chrono/std::chrono::weekday::February", "chrono/std::chrono::weekday::March","chrono/std::chrono::weekday::April","chrono/std::chrono::weekday::May","chrono/std::chrono::weekday::June","chrono/std::chrono::weekday::July","chrono/std::chrono::weekday::August","chrono/std::chrono::weekday::September","chrono/std::chrono::weekday::October","chrono/std::chrono::weekday::November","chrono/std::chrono::weekday::December","chrono/std::chrono::weekday::operator++", "chrono/std::chrono::weekday::operator--", "chrono/std::chrono::weekday::operator unsigned", "chrono/std::chrono::weekday::ok", "chrono/std::chrono::weekday::iso_encoding", "chrono/std::chrono::weekday::c_encoding"]
helpviewer_keywords: ["std::chrono [C++], weekday"]
---
Expand Down Expand Up @@ -78,6 +78,30 @@ Construct a `weekday` with value *`wd`*.
3\) Computes what day of the week corresponds to the `std::chrono::sys_days` value `dp`, and constructs a `weekday` using that day.\
4\) Computes the day of the week that corresponds to the `std::chrono::local_days` value `dp`, and constructs a `weekday` using that day. It behaves as if you created the `weekday` using `weekday(std::chrono::sys_days(dp.time_since_epoch()))`.

### Example: Create a `weekday`

```cpp
// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
weekday wd{ Wednesday };
weekday wd2{ 3 };
std::cout << wd << '\n' << wd2;

return 0;
}
```

```output
Wednesday
Wednesday
```

## <a name="c_encoding"></a> `c_encoding`

```cpp
Expand Down Expand Up @@ -138,17 +162,16 @@ using namespace std::chrono;

int main()
{
std::chrono::weekday y{4};
std::chrono::weekday wd{Thursday};

std::cout << y << " " << ++y << "\n"; // constexpr weekday& operator++() noexcept
std::cout << y << " " << y++ << "\n"; // constexpr weekday operator++(int) noexcept
std::cout << y << "\n";
std::cout << wd << " " << ++wd << "\n"; // constexpr weekday& operator++() noexcept
std::cout << wd << " " << wd++ << "\n"; // constexpr weekday operator++(int) noexcept
std::cout << wd << "\n";

return 0;
}
```

Output:
```output
Thu Fri
Fri Fri
Expand Down Expand Up @@ -185,7 +208,7 @@ using namespace std::chrono;

int main()
{
weekday y = weekday{4};
weekday y = weekday{Thursday};

cout << y << " " << --y << "\n"; // constexpr weekday& operator--() noexcept
cout << y << " " << y-- << "\n"; // constexpr weekday operator--(int) noexcept
Expand All @@ -195,8 +218,6 @@ int main()
}
```

Output:

```output
Thu Wed
Wed Wed
Expand Down Expand Up @@ -267,7 +288,7 @@ using namespace std::chrono;

int main()
{
constexpr auto firstMondayInJanuary =
constexpr auto firstMondayInJanuary =
year_month_day{ Monday[2] / January / 2021y };

std::cout << firstMondayInJanuary << "\n";
Expand Down
6 changes: 3 additions & 3 deletions docs/standard-library/weekdayindexed-class.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: weekday_indexed Class"
title: "weekday_indexed class"
ms.date: "06/07/2021"
ms.date: "06/25/2021"
f1_keywords: ["chrono/std::chrono::weekday_indexed", "chrono/std::chrono::weekday_indexed::ok", "std::chrono::weekday_indexed::weekday", "std::chrono::weekday_indexed::ok"]
helpviewer_keywords: ["std::chrono [C++], weekday_indexed"]
---
Expand Down Expand Up @@ -69,7 +69,7 @@ using namespace std::chrono;
int main()
{
constexpr auto wdi = weekday_indexed(Monday, 1);
constexpr auto wdi = weekday_indexed{Monday, 1};
std::cout << wdi;
return 0;
Expand Down Expand Up @@ -113,7 +113,7 @@ The weekday value.

int main()
{
constexpr auto wdi = weekday_indexed(Monday, 1);
constexpr auto wdi = weekday_indexed{ Monday, 1 };
std::cout << wdi << "\n";

return 0;
Expand Down
8 changes: 3 additions & 5 deletions docs/standard-library/weekdaylast-class.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: weekday_last Class"
title: "weekday_last class"
ms.date: "06/07/2021"
ms.date: "06/25/2021"
f1_keywords: ["chrono/std::chrono::weekday_last", "chrono/std::chrono::weekday_last::ok", "std::chrono::weekday_last::weekday", "chrono/std::chrono::weekday_last::ok", "chrono/std::chrono::weekday_last::weekday"]
helpviewer_keywords: ["std::chrono [C++], weekday_last"]
---
Expand Down Expand Up @@ -103,17 +103,15 @@ using namespace std::chrono;

int main()
{
constexpr auto wdl = Monday[last]; // lastWeekday is the last Monday of an unspecified month
constexpr auto wdl{ Monday[last] }; // wdl is the last Monday of an unspecified month
std::cout << wdl.weekday() << "\n";

return 0;
}
```

Output:

```output
Monday
Mon
```

## See also
Expand Down
15 changes: 12 additions & 3 deletions docs/standard-library/year-class.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: "Learn more about: year Class"
title: "year class"
ms.date: "06/07/2021"
ms.date: "06/25/2021"
f1_keywords: ["chrono/std::chrono::year", "chrono/std::chrono::year::operator++", "chrono/std::chrono::year::operator--", "chrono/std::chrono::year::operator+=", "chrono/std::chrono::year::operator-=", "chrono/std::chrono::year::operator int", "chrono/std::chrono::year::is_leap", "chrono/std::chrono::year::max", "chrono/std::chrono::min", "chrono/std::chrono::year::ok"]
helpviewer_keywords: ["std::chrono [C++], year"]
---
Expand Down Expand Up @@ -78,6 +78,7 @@ Construct a `year` with value *`y`*.
### Example: Create a `year`
```cpp
// compile using: /std:c++latest
#include <iostream>
#include <chrono>
Expand Down Expand Up @@ -160,6 +161,7 @@ Returns `*this`
### Example: unary `operator+`

```cpp
// compile using: /std:c++latest
#include <iostream>
#include <chrono>

Expand Down Expand Up @@ -196,6 +198,7 @@ Add 1 to the year value.
### Example: `operator++`

```cpp
// compile using: /std:c++latest
#include <iostream>
#include <chrono>

Expand Down Expand Up @@ -237,6 +240,7 @@ Returns a negated copy of the `year`.
### Example: unary `operator-`

```cpp
// compile using: /std:c++latest
#include <iostream>
#include <chrono>

Expand Down Expand Up @@ -274,6 +278,7 @@ Subtract 1 from the year value.
### Example: `operator--`

```cpp
// compile using: /std:c++latest
#include <iostream>
#include <chrono>

Expand Down Expand Up @@ -335,7 +340,6 @@ The number of years to subtract.

`*this`. If the decremented result is less than -32768, it's set to 32767.


## <a name="op_int"></a> `operator int`

Get the `year` value.
Expand All @@ -351,7 +355,9 @@ The value of the `year`
### Example: `operator int()`

```cpp
#include <iostream>
// compile using: /std:c++latest

#include <iostream>
#include <chrono>

using namespace std::chrono;
Expand All @@ -374,5 +380,8 @@ int main()

[`year_month`](year-month-class.md)\
[`year_month_day`](year-month-day-class.md)\
[`year_month_day_last`](year-month-day-last-class.md)\
[`year_month_weekday`](year-month-weekday-class.md)\
[`year_month_weekday_last`](year-month-weekday-last-class.md)\
[`<chrono>`](chrono.md)\
[Header Files Reference](cpp-standard-library-header-files.md)
Loading