std::chrono...s_local_time(3)
okay bestie, you're in the C++ Standard Libary manual on page std::chrono...s_local_time(3) β and this whole page is about std::chrono::ambiguous_local_time. it's giving βtime zones said both, actuallyβ energy. π°οΈπ
π NAME π
std::chrono::ambiguous_local_time β std::chrono::ambiguous_local_time. yes bestie, that's the name, twice, and it's the exception type for ambiguous local-time conversions. no cap.
β¨ Synopsis β¨
Defined in header <chrono>:
Defined in header <chrono>
class ambiguous_local_time; (since C++20)
Defines a type of object to be thrown as exception to report that an attempt was made to convert an ambiguous std::chrono::local_time to a std::chrono::sys_time without specifying a std::chrono::choose (such as choose::earliest or choose::latest). periodt.
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 take a std::chrono::local_time). lowkey iconic of it to show up exactly where the time-zone math gets messy. π¦
The page also has an inheritance diagram, and the image filename is literally this: std-chrono-ambiguous local time-inheritance.svg β that's the Inheritance diagram label, bestie. keep the spaces exactly.
π«Ά Member functions π«Ά
constructorβ constructs the exception object (public member function)operator=β replaces the exception object (public member function)whatβ returns the explanatory string (public member function)
π std::chrono::ambiguous_local_time::ambiguous_local_time π
the signature is this, overloads and all:
template< class Duration >
ambiguous_local_time( const std::chrono::local_time<Duration>& tp,
const std::chrono::local_info& i ); (1) (since C++20)
ambiguous_local_time( const ambiguous_local_time& other ) (2) (since C++20)
noexcept;
Constructs the exception object.
- The explanatory string returned by
what()is equivalent to that produced byos.str()after the following code:
std::ostringstream os;
os << tp << " is ambiguous. It could be\n"
<< tp << ' ' << i.first.abbrev << " == "
<< tp - i.first.offset << " UTC or\n"
<< tp << ' ' << i.second.abbrev << " == "
<< tp - i.second.offset << " UTC";
β οΈ bestie, the behavior is undefined if i.result != std::chrono::local_info::ambiguous. undefined behavior is the final boss β do not test it. π
- Copy constructor. If
*thisandotherboth have dynamic typestd::chrono::ambiguous_local_timethenstd::strcmp(what(), other.what()) == 0.
π Parameters π
tpβ the time point for which conversion was attemptediβ astd::chrono::local_infodescribing the result of the conversion attemptotherβ anotherambiguous_local_timeto copy
π Exceptions π
May throw std::bad_alloc.
π Notes π
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. that's the note, bestie β it's allocated separately so copying stays noexcept-ish in spirit.
π std::chrono::ambiguous_locale_time::operator= π
yes, the page really spells this oneambiguous_locale_timewith anehere, bestie β it's right there in the original, so keep it exactly. π
ambiguous_locale_time& operator=( const ambiguous_locale_time& other ) noexcept; (since C++20)
Assigns the contents with those of other. If *this and other both have dynamic type std::chrono::ambiguous_locale_time then std::strcmp(what(), other.what()) == 0 after assignment.
π Parameters π
otherβ another exception object to assign with
π Return value π
*this
π std::chrono::ambiguous_locale_time::what π
virtual const char* what() const noexcept; (since C++20)
Returns the explanatory string.
πΈ Parameters πΈ
(none)
β Return value β
Pointer to a null-terminated string with explanatory information. The string is suitable for conversion and display as a std::wstring. The pointer is guaranteed to be valid at least until the exception object from which it is obtained is destroyed, or until a non-const member function (e.g. copy assignment operator) on the exception object is called.
π§ Notes π§
Implementations are allowed but not required to override what().
π Inherited from std::runtime_error π
π Inherited from std::exception π
π«Ά Member functions π«Ά
destructorβ destroys the exception object[virtual](virtual public member function ofstd::exception)whatβ returns an explanatory string[virtual](virtual public member function ofstd::exception)
π See also π
nonexistent_local_timeβ exception thrown to report that a local time is nonexistent(C++20)(class)
source/version/date from the footer, bestie: http://cppreference.com, 2024.06.10, and std::chrono...s_local_time(3). go forth and disambiguate responsibly πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms