Skip to content

Commit 01d3ce0

Browse files
TylerMSFTTylerMSFT
andauthored
Twhitney chrono (#3530)
* chrono c++20 work * first draft * draft * fix links * testing formatting * add format options * finish draft for chrono::days * start month, couple fixes for day * month draft * tweak to spaceship operator description * drafting year * draft year * draft weekday, update missing operators * acrolinx * finish year * fix weekday sample * add hh_mm_ss class docs * add weekday-last-class * added weekday_indexed-class, updated code snippets * integrate Colin's work and update some code examples * fix links, incorp tech review * add flag/class table * fix links * fix filenames, links * acrolinx * tech review * PR review feedback * pr review feedback * fix link Co-authored-by: TylerMSFT <[email protected]>
1 parent b152dfe commit 01d3ce0

16 files changed

+3232
-143
lines changed

docs/standard-library/chrono-functions.md

Lines changed: 818 additions & 28 deletions
Large diffs are not rendered by default.

docs/standard-library/chrono-literals.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
description: "Learn more about: `chrono` literals"
33
title: "chrono literals"
44
f1_keywords: ["chrono/std::literals::chrono_literals", "std::literals::chrono_literals", "chrono_literals"]
5-
ms.date: "01/15/2021"
5+
ms.date: "4/23/2021"
66
---
77
# `chrono` literals
88

@@ -13,6 +13,9 @@ ms.date: "01/15/2021"
1313
```cpp
1414
inline namespace literals {
1515
inline namespace chrono_literals {
16+
// return integral days
17+
constexpr std::chrono::day operator ""d(unsigned long long d) noexcept;
18+
1619
// return integral hours
1720
constexpr chrono::hours operator"" h(unsigned long long Val);
1821

@@ -49,6 +52,8 @@ inline namespace literals {
4952
// return floating-point nanoseconds
5053
constexpr chrono::duration<double, nano> operator"" ns(long double Val);
5154

55+
// return integral year
56+
constexpr chrono::year operator""y(unsigned long long y) noexcept; // C++ 20
5257
} // inline namespace chrono_literals
5358
} // inline namespace literals
5459
```
@@ -62,7 +67,9 @@ The literals that take a **`long long`** argument return a value or the correspo
6267
The following examples show how to use the `chrono` literals.
6368
6469
```cpp
65-
constexpr auto day = 24h;
70+
constexpr auto day = 14d; // If the value > 255`, then the stored value is unspecified.
71+
constexpr auto twoDays = 48h;
6672
constexpr auto week = 24h* 7;
6773
constexpr auto my_duration_unit = 108ms;
74+
constexpr auto theYear = 2021y;
6875
```

0 commit comments

Comments
 (0)