std::chrono::zoned_time<Duration,TimeZonePtr>:: zoned_time
|
zoned_time
(
)
;
|
(1) | (seit C++20) |
|
zoned_time
(
const
std::
chrono
::
sys_time
<
Duration
>
&
st
)
;
|
(2) | (seit C++20) |
|
zoned_time
(
const
zoned_time
&
other
)
=
default
;
|
(3) | (seit C++20) |
|
template
<
class
Duration2
>
zoned_time ( const std:: chrono :: zoned_time < Duration2, TimeZonePtr > & other ) ; |
(4) | (seit C++20) |
|
explicit
zoned_time
(
TimeZonePtr z
)
;
|
(5) | (seit C++20) |
|
explicit
zoned_time
(
std::
string_view
name
)
;
|
(6) | (seit C++20) |
|
zoned_time
(
TimeZonePtr z,
const
std::
chrono
::
sys_time
<
Duration
>
&
st
)
;
|
(7) | (seit C++20) |
|
zoned_time
(
std::
string_view
name,
const
std::
chrono
::
sys_time
<
Duration
>
&
st
)
;
|
(8) | (seit C++20) |
|
zoned_time
(
TimeZonePtr z,
const
std::
chrono
::
local_time
<
Duration
>
&
tp
)
;
|
(9) | (seit C++20) |
|
zoned_time
(
std::
string_view
name,
const
std::
chrono
::
local_time
<
Duration
>
&
tp
)
;
|
(10) | (seit C++20) |
|
zoned_time
(
TimeZonePtr z,
const
std::
chrono
::
local_time
<
Duration
>
&
tp,
std:: chrono :: choose c ) ; |
(11) | (seit C++20) |
|
zoned_time
(
std::
string_view
name,
const std:: chrono :: local_time < Duration > & tp, std:: chrono :: choose c ) ; |
(12) | (seit C++20) |
|
template
<
class
Duration2,
class
TimeZonePtr2
>
zoned_time
(
TimeZonePtr z,
|
(13) | (seit C++20) |
|
template
<
class
Duration2,
class
TimeZonePtr2
>
zoned_time
(
TimeZonePtr z,
|
(14) | (seit C++20) |
|
template
<
class
Duration2,
class
TimeZonePtr2
>
zoned_time
(
std::
string_view
name,
|
(15) | (seit C++20) |
|
template
<
class
Duration2,
class
TimeZonePtr2
>
zoned_time
(
std::
string_view
name,
|
(16) | (seit C++20) |
Konstruiert ein
zoned_time
-Objekt, initialisiert den gespeicherten Zeitzonenzeiger und Zeitpunkt gemäß der folgenden Tabelle, wobei
traits
für
std::
chrono
::
zoned_traits
<
TimeZonePtr
>
steht:
| Überladung |
Zeitzonen-Zeiger (bezeichnet als
zone
)
|
Zeitpunkt (ein std:: chrono :: sys_time < duration > ) | Anmerkungen |
|---|---|---|---|
| (1) | traits :: default_zone ( ) | Standardkonstruiert | (a) |
| (2) |
st
|
||
| (3) | other. get_time_zone ( ) | other. get_sys_time ( ) | (b) |
| (4) | other. get_time_zone ( ) | other. get_sys_time ( ) | (e) |
| (5) | std :: move ( z ) | Standardkonstruiert | |
| (6) | traits :: locate_zone ( name ) | (c) | |
| (7) | std :: move ( z ) |
st
|
|
| (8) | traits :: locate_zone ( name ) | (c) | |
| (9) | std :: move ( z ) | zone - > to_sys ( tp ) | (d) |
| (10) | traits :: locate_zone ( name ) | (c,d) | |
| (11) | std :: move ( z ) | zone - > to_sys ( tp, c ) | (d) |
| (12) | traits :: locate_zone ( name ) | (c,d) | |
| (13,14) | std :: move ( z ) | zt. get_sys_time ( ) | (e) |
| (15,16) | traits :: locate_zone ( name ) | (c,e) |
name
(6,8,10,12,15,16)
nehmen nicht an der Überladungsauflösung teil, falls
traits
::
locate_zone
(
name
)
nicht wohlgeformt ist oder wenn dieser Ausdruck nicht in
TimeZonePtr
konvertierbar ist.
Duration2
(4,13-16)
nehmen nicht an der Überladungsauflösung teil, wenn
Duration2
nicht in
Duration
konvertierbar ist.
Das Verhalten ist undefiniert, wenn der Zeiger auf die Zeitzone (wie oben beschrieben initialisiert) nicht auf eine Zeitzone verweist.
Hinweise
zoned_time
besitzt keinen Move-Konstruktor und der Versuch, eines zu verschieben, führt stattdessen eine Kopie unter Verwendung des standardmäßig definierten Kopierkonstruktors aus
(3)
. Wenn daher
TimeZonePtr
ein nur-verschiebbarer Typ ist, ist
zoned_time
unverschiebbar: es kann weder verschoben noch kopiert werden.
Die Konstruktoren (14,16) akzeptieren einen std::chrono::choose Parameter, aber dieser Parameter hat keine Auswirkung.
Beispiel
#include <chrono> #include <iostream> #include <string_view> int main() { using std::chrono_literals::operator""y; using std::operator""sv; std::cout << std::chrono::zoned_time{} << " : default\n"; constexpr std::string_view location1{"America/Phoenix"sv}; std::cout << std::chrono::zoned_time{location1} << " : " << location1 << '\n'; const std::chrono::time_zone* timeZonePtr = std::chrono::locate_zone("UTC"); std::cout << std::chrono::zoned_time{timeZonePtr} << " : UTC time zone\n"; constexpr auto location2{"Europe/Rome"sv}; std::cout << std::chrono::zoned_time{location2, std::chrono::local_days{2021y/12/31}} << " : " << location2 << '\n'; constexpr auto location3{"Europe/Rome"sv}; constexpr auto some_date = std::chrono::sys_time<std::chrono::days>{2021y/12/31}; std::cout << std::chrono::zoned_time{location3, some_date} << " : " << location3 << '\n'; const auto now = std::chrono::floor<std::chrono::minutes>(std::chrono::system_clock::now()); constexpr auto location4{"Europe/Rome"sv}; std::cout << std::chrono::zoned_time{location4, now} << " : " << location4 << '\n'; constexpr auto NewYork{"America/New_York"sv}; constexpr auto Tokyo{"Asia/Tokyo"sv}; const std::chrono::zoned_time tz_Tokyo{Tokyo, now}; const std::chrono::zoned_time tz_NewYork{NewYork, now}; std::cout << std::chrono::zoned_time{Tokyo, tz_NewYork} << " : " << Tokyo << '\n'; std::cout << std::chrono::zoned_time{NewYork, tz_Tokyo} << " : " << NewYork << '\n'; }
Mögliche Ausgabe:
1970-01-01 00:00:00 UTC : default 1969-12-31 17:00:00 MST : America/Phoenix 1970-01-01 00:00:00 UTC : UTC time zone 2021-12-31 00:00:00 CET : Europe/Rome 2021-12-31 01:00:00 CET : Europe/Rome 2021-09-20 23:04:00 CEST : Europe/Rome 2021-09-21 06:04:00 JST : Asia/Tokyo 2021-09-20 17:04:00 EDT : America/New_York