Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::chrono::locate_zone

      From cppreference.com
      <cpp‎ |chrono
       
       
      Date and time library
       
      Defined in header<chrono>
      conststd::chrono::time_zone* locate_zone(std::string_view tz_name);
      (since C++20)

      Convenience function for locating a time zone in thetime zone database. Equivalent tostd::chrono::get_tzdb().locate_zone(tz_name).

      Contents

      [edit]Parameters

      tz_name - a time zone name to locate

      [edit]Exceptions

      std::runtime_error if the specified time zone cannot be found, or if this is the first reference to the time zone database and the time zone database cannot be initialized.

      [edit]Notes

      A call to this function that is the first reference to the time zone database will cause it to be initialized.

      [edit]Example

      Run this code
      #include <chrono>#include <iostream> int main(){try{for(constauto zone:{"Atlantic/Bermuda","Alcatraz"})std::cout<< std::chrono::locate_zone(zone)->name()<<'\n';}catch(conststd::runtime_error& ex){std::cout<< ex.what()<<'\n';}}

      Possible output:

      Atlantic/Bermudastd::chrono::tzdb: cannot locate zone: Alcatraz

      [edit]See also

      locate a time zone with the given name
      (public member function ofstd::chrono::tzdb)[edit]
      accesses and controls the global time zone database information
      (function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/chrono/locate_zone&oldid=180426"

      [8]ページ先頭

      ©2009-2025 Movatter.jp