utc_clock_formatter

utc_clock_formatter (utc_clock 포맷터)

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

출처: cppreference

본문

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

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

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

  • %Z를 사용하면 "UTC"로 치환돼요.
  • %z 또는 수정된 변형을 사용하면 0min 오프셋이 포맷돼요.
  • 인자가 윤초 삽입 시간의 시각을 나타내고 초 필드가 포맷되면, 필드의 정수 부분이 "60"으로 치환돼요.

예제 (Example)

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

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

더 알아보기 (Learn more)

cppreference