std::chrono::zoned_time::zoned_time

From cppreference.com
< cpp‎ | chrono‎ | zoned time
 
 
 
Date and time utilities
(C++11)
(C++11)
Clocks
(C++20)
                                                  
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
Calendars
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
Time zones
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
C-style date and time
 
 
zoned_time();
(1) (since C++20)
zoned_time(const std::chrono::sys_time<Duration>& st);
(2) (since C++20)
zoned_time(const zoned_time& other) = default;
(3) (since C++20)
template< class Duration2 >
zoned_time(const std::chrono::zoned_time<Duration2, TimeZonePtr>& other);
(4) (since C++20)
explicit zoned_time(TimeZonePtr z);
(5) (since C++20)
explicit zoned_time(std::string_view name);
(6) (since C++20)
zoned_time(TimeZonePtr z, const std::chrono::sys_time<Duration>& st);
(7) (since C++20)
zoned_time(std::string_view name, const std::chrono::sys_time<Duration>& st);
(8) (since C++20)
zoned_time(TimeZonePtr z, const std::chrono::local_time<Duration>& tp);
(9) (since C++20)
zoned_time(std::string_view name, const std::chrono::local_time<Duration>& tp);
(10) (since C++20)
zoned_time(TimeZonePtr z, const std::chrono::local_time<Duration>& tp,
           std::chrono::choose c);
(11) (since C++20)
zoned_time(std::string_view name, const std::chrono::local_time<Duration>& tp,
           std::chrono::choose c);
(12) (since C++20)
template< class Duration2, class TimeZonePtr2 >
zoned_time(TimeZonePtr z, const std::chrono::zoned_time<Duration2, TimeZonePtr2>& zt);
(13) (since C++20)
template< class Duration2, class TimeZonePtr2 >
zoned_time(TimeZonePtr z, const std::chrono::zoned_time<Duration2, TimeZonePtr2>& zt, choose);
(14) (since C++20)
template< class Duration2, class TimeZonePtr2 >
zoned_time(std::string_view name, const std::chrono::zoned_time<Duration2, TimeZonePtr2>& zt);
(15) (since C++20)
template< class Duration2, class TimeZonePtr2 >
zoned_time(std::string_view name, const std::chrono::zoned_time<Duration2, TimeZonePtr2>& zt, choose);
(16) (since C++20)

Constructs a zoned_time object, initializing the stored time zone pointer and time point according to the following table, where traits is std::chrono::zoned_traits<TimeZonePtr>:

Overload Time zone pointer (denoted zone) Time point (a std::chrono::sys_time<duration>) Notes
(1) traits::default_zone() default constructed (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) default constructed
(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)
a) Constructors specified to call traits::default_zone() (1-2) do not participate in overload resolution if that expression is not well-formed.
b) The defaulted copy constructor (3) is defined as deleted if std::is_copy_constructible_v<TimeZonePtr> is false.
c) Constructors with a std::string_view parameter name (6,8,10,12,15-16) do not participate in overload resolution if traits::locate_zone(name) is not well-formed or if that expression is not convertible to TimeZonePtr.
d) Constructors specified to call zone->to_sys (9-12) do not participate in overload resolution if that call expression is not well-formed or if the result is not convertible to std::chrono::sys_time<duration>.
e) Constructors with a template parameter Duration2 (4,13-16) do not participate in overload resolution if Duration2 is not convertible to Duration.

The behavior is undefined if the time zone pointer (initialized as described above) does not refer to a time zone.

Notes

zoned_time does not have a move constructor and attempting to move one will perform a copy instead using the defaulted copy constructor (3). Thus, when TimeZonePtr is a move-only type, zoned_time is immovable: it can be neither moved nor copied.

The constructors (14,16) accept a std::chrono::choose parameter, but that parameter has no effect.