tai_clock_formatter

tai_clock_formatter (tai_clock 포맷터)

std::formatter<std::chrono::tai_time> 특수화가 std::chrono::tai_time의 포맷 규칙을 정의해요. std::format과 함께 사용해요.

출처: cppreference

본문

std::formatter<std::chrono::time_point<std::chrono::tai_clock, Duration>> 특수화는 <chrono> 헤더에 정의되어 있어요. C++20부터 사용 가능해요.

template< class Duration, class CharT >
struct std::formatter<std::chrono::tai_time<Duration>, CharT>;

std::chrono::tai_time의 포맷 규칙을 정의해요.

  • %Z를 사용하면 "TAI"로 치환돼요.
  • %z 또는 수정된 변형을 사용하면 0min 오프셋이 포맷돼요.
  • 포맷된 날짜와 시간은 std::chrono::sys_time<Duration>(tp.time_since_epoch()) - std::chrono::days(4383)으로 초기화된 std::chrono::sys_time과 동등해요 (TAI는 UTC보다 37초 앞서요).

예제 (Example)

#include <chrono>
#include <format>
#include <iostream>

int main()
{
    auto tt = std::chrono::tai_clock::now();
    std::cout << std::format("{:%F %T %Z}", tt) << '\n';
}

더 알아보기 (Learn more)

cppreference