sys_info_formatter

sys_info_formatter (sys_info 포맷터)

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

출처: cppreference

본문

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

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

std::chrono::sys_info(시간대 전환 정보)의 포맷 규칙을 정의해요.

  • %Zabbrev(약어)로 치환돼요.
  • %z / %Ez / %Ozoffset으로 치환돼요.

std::formatter 특수화는 보통 직접 접근하지 않고 std::chrono::format 같은 포맷 함수를 통해 사용돼요.

예제 (Example)

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

int main()
{
    auto tz = std::chrono::current_zone();
    auto info = tz->get_info(std::chrono::system_clock::now());
    std::cout << std::format("{} {}", info.abbrev, info.offset) << '\n';
}

더 알아보기 (Learn more)

cppreference