Namespaces
Variants
Views
Actions

std::chrono::nonexistent_local_time

From cppreference.com
< cpp‎ | chrono
 
 
 
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
 
Defined in header <chrono>
class nonexistent_local_time;
(since C++20)

Defines a type of object to be thrown as exception to report that an attempt was made to convert a nonexistent std::chrono::local_time to a std::chrono::sys_time without specifying a std::chrono::choose (such as choose::earliest or choose::latest).

This exception is thrown by std::chrono::time_zone::to_sys and functions that call it (such as the constructors of std::chrono::zoned_time that takes a std::chrono::local_time).

cpp/error/exceptioncpp/error/runtime errorstd-chrono-nonexistent local time-inheritance.svg
About this image

Inheritance diagram

Contents

[edit] Member functions

(constructor)
constructs the exception object
(public member function)

std::chrono::nonexistent_local_time::nonexistent_local_time

template< class Duration >

nonexistent_local_time(const std::chrono::local_time<Duration>& tp,

                       const std::chrono::local_info& i);

Constructs the exception object. The explanatory string returned by what() is equivalent to that produced by os.str() after the following code:

std::ostringstream os;
os << tp << " is in a gap between\n"
   << std::chrono::local_seconds(i.first.end.time_since_epoch()) + i.first.offset 
   << ' ' << i.first.abbrev << " and\n"
   << std::chrono::local_seconds(i.second.begin.time_since_epoch()) + i.second.offset
   << ' ' << i.second.abbrev
   << " which are both equivalent to\n"
   << i.first.end << " UTC";

Because copying a standard library class derived from std::exception is not permitted to throw exceptions, this message is typically stored internally as a separately-allocated reference-counted string.

The behavior is undefined if i.result != std::chrono::local_info::nonexistent.

Parameters

tp - the time point for which conversion was attempted
i - a std::chrono::local_info describing the result of the conversion attempt

Exceptions

May throw std::bad_alloc

Inherited from std::exception

Member functions

[virtual]
destroys the exception object
(virtual public member function of std::exception) [edit]
[virtual]
returns an explanatory string
(virtual public member function of std::exception) [edit]