local_info

local_info (로컬 시간대 정보)

로컬 시각을 시스템/UTC 시각으로 변환할 때 필요한 시간대 정보를 담는 타입이에요. <chrono> 헤더, C++20부터.

출처: cppreference

본문

std::chrono::local_info는 로컬 시각을 절대 시각으로 해석하는 데 필요한 정보를 담아요.

struct local_info {
    static constexpr int unique      = 0;
    static constexpr int nonexistent = 1;
    static constexpr int ambiguous   = 2;

    int result;                     // unique / nonexistent / ambiguous
    std::chrono::sys_seconds first;
    std::chrono::sys_seconds second;
};
  • result: 변환 결과. 0(unique, 유일), 1(nonexistent, 존재하지 않음), 2(ambiguous, 모호) 중 하나예요.
  • first, second: 하절기 전환 등으로 인한 두 개의 가능한 절대 시각(구간). unique면 secondfirst와 같아요.

std::chrono::time_zone::to_local 같은 변환 과정에서 로컬 시각이 모호(하절기 중복)하거나 존재하지 않을 때(하절기 생략) 이를 보고받는 데 쓰여요. ambiguous_local_time/nonexistent_local_time 예외 뒤에 이 구조체가 있어요.

std::chrono::local_info li = tz->get_info(...);  // (구현에 따라)

모호/없는 로컬 시각을 정밀하게 다루는 시간대 처리에서 사용해요. 일반 응용에서는 거의 직접 쓰지 않아요.

더 알아보기 (Learn more)

cppreference