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
new local_info_struct & sys_info_struct plus updates (#3762)
* new local_info_struct & sys_info_struct plus updates
* acrolinx
* finish draft of local_info and sys_info, and update time_zone with an example of how to get one
* fix typos
* stash work so far on zoned_time class
* draft stub
* fix merge conflicts
* tech review
* add choose-enum, more zoned_time class work
* draft zoned_time
* read through fixes
* acrolinx
* cleanup
* a little word smithing
* tech review
* acrolinx and last of tech review
Co-authored-by: TylerMSFT <[email protected]>
description: "enum used to specify how to handle ambiguous or nonexistent local times when resolving a time in a time zone"
4
+
ms.date: 09/16/2021
5
+
f1_keywords: ["chrono/std::choose"]
6
+
helpviewer_keywords: ["std::choose"]
7
+
---
8
+
9
+
# `choose` enum
10
+
11
+
Used with [`time_zone`](time-zone-class.md) and [`zoned_time`](zoned-time-class.md) to indicate how to handle ambiguous or nonexistent local times when resolving a time in a time zone.
12
+
13
+
## Syntax
14
+
15
+
```cpp
16
+
enumclasschoose { // C++ 20
17
+
earliest,
18
+
latest
19
+
};
20
+
```
21
+
22
+
### Members
23
+
24
+
|Element|Description|
25
+
|-|-|
26
+
| `earliest` | If a time conversion in a time zone is ambiguous or nonexistent, uses the earlier time point. |
27
+
| `latest` | If a time conversion in a time zone is ambiguous or nonexistent, uses the later time point. |
28
+
29
+
## Remarks
30
+
31
+
If a local time doesn't exist for the time zone, `earliest` and `latest` result in the same time point.
32
+
When `choose` isn't passed and an ambiguous or nonexistent time results, either the exception `std::chrono::ambiguous_local_time` or `std::chrono::nonexistent_local_time` is thrown, respectively.
33
+
34
+
## Requirements
35
+
36
+
**Header:** `<chrono>` (since C++20)
37
+
38
+
**Namespace:** `std::chrono`
39
+
40
+
Compiler option:[`/std:c++latest`](../build/reference/std-specify-language-standard-version.md) is required.
@@ -974,9 +1001,15 @@ The `month_weekday` to output.
974
1001
*`mwdl`*\
975
1002
The `month_weekday_last` to output.
976
1003
1004
+
*`si`*\
1005
+
The `sys_info` to output.
1006
+
977
1007
*`t`*\
978
1008
The `local_time`, `gps_time`, `tai_time`, or `utc_time` to output.
979
1009
1010
+
*`TimeZonePtr`*\
1011
+
A pointer to the [time_zone](time-zone-class.md) stored in the [`zoned_time`](zoned-time-class.md).
1012
+
980
1013
*`wd`*\
981
1014
The `weekday` to output.
982
1015
@@ -1004,6 +1037,9 @@ The `year_month_weekday` to output.
1004
1037
*`ymwdl`*\
1005
1038
The `year_month_weekday_last` to output.
1006
1039
1040
+
*`zt`*\
1041
+
The `zoned_time` to output.
1042
+
1007
1043
### Return value
1008
1044
1009
1045
The output stream you passed in, `os`
@@ -1050,6 +1086,12 @@ The output stream you passed in, `os`
1050
1086
1051
1087
20\) The `local_time` is output as the number of seconds since the clock's epoch. It's output as though by `os << std::chrono::sys_time<Duration>(some_local_time.time_since_epoch());`. For example, if `some_local_time` is August 18, 2021 3:13pm, the output is `1597792380`.
1052
1088
1089
+
21\) In Microsoft's implementation, a `sys_info` is output as its `begin`, `end`, `offset`, `save`, and `abbrev` fields. For example: `begin: 2021-03-14 10:00:00, end: 2021-11-07 09:00:00, offset: -25200s, save: 60min, abbrev: PDT`
1090
+
1091
+
22\) In Microsoft's implementation, a `local_info` is output as yyyy-mm-dd hh:mm::ss.ssssss. For example, `2021-09-17 13:55:59.6590120`
1092
+
1093
+
23\) The local time in the `zoned_time` (obtained as `zt.get_local_time()`) is output using the format yyyy-mm-dd hh:mm:ss timezone. For example, `2021-09-15 10:45:00 GMT-6`
0 commit comments