• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <chrono>

    std::chrono::make12

    namespace std::chrono {
      constexpr hours make12(const hours& h) noexcept;
    }
    

    概要

    24時間ベースの時間を12時間ベースの時間範囲に変換する。

    戻り値

    • hを12時間時計での範囲[1h, 12h]の等価な時間を返す
    • h[0h, 23h]の範囲外である場合、未規定の値を返す

    #include <cassert>
    #include <chrono>
    
    namespace chrono = std::chrono;
    using namespace std::chrono_literals;
    
    int main()
    {
      assert(chrono::make12(0h) == 12h);
      assert(chrono::make12(3h) == 3h);
      assert(chrono::make12(12h) == 12h);
      assert(chrono::make12(15h) == 3h);
      assert(chrono::make12(23h) == 11h);
    }
    

    出力

    バージョン

    言語

    • C++20

    処理系