• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    function
    <chrono>

    std::chrono::gps_clock::to_utc

    template <class Duration>
    static utc_time<common_type_t<Duration, seconds>>
      to_utc(const gps_time<Duration>& t) noexcept;
    

    概要

    GPS時間からUTC時間に変換する。

    戻り値

    ここで315964809は、システム時間のエポック1970年1月1日とGPS時間のエポック1980年1月6日 (この年の最初の日曜日) との差である秒数に、その間に挿入されたうるう秒である9秒を加算した秒数である。

    #include <iostream>
    #include <chrono>
    
    namespace chrono = std::chrono;
    using namespace std::chrono_literals;
    
    int main()
    {
      auto tt = chrono::clock_cast<chrono::gps_clock>(chrono::sys_days{2019y/10/24});
      auto ut = chrono::gps_clock::to_utc(tt);
    
      // うるう秒
      chrono::leap_second_info info = chrono::get_leap_second_info(ut);
    
      std::cout << tt << " GPS" << std::endl;
      std::cout << ut << " UTC" << std::endl;
      std::cout << info.elapsed.count() << std::endl;
    }
    

    出力

    2019-10-24 00:00:18 GPS
    2019-10-24 00:00:00 UTC
    27
    

    バージョン

    言語

    • C++20

    処理系