chrono_local_info
chrono_local_info (로컬 시간 변환 정보)
std::chrono::local_info는 로컬 시간을 UTC로 변환할 때의 결과 정보를 담는 타입이에요. unique(유일), nonexistent(부재), ambiguous(모호) 세 결과를 구분해요.
출처: cppreference
본문
std::chrono::local_info는 <chrono> 헤더에 정의된 구조체예요. C++20부터 사용 가능해요.
struct local_info {
static constexpr int unique = 0;
static constexpr int nonexistent = 1;
static constexpr int ambiguous = 2;
int result;
sys_info first;
sys_info second;
};
result—unique,nonexistent,ambiguous중 하나.first/second— 관련 시간대 전환 정보 (sys_info).
time_zone::get_info(local_time) 같은 호출이 이 타입을 반환해요. 모호하거나 존재하지 않는 로컬 시간을 처리할 때 이 정보를 사용해요.
예제 (Example)
#include <chrono>
#include <iostream>
int main()
{
auto tz = std::chrono::current_zone();
auto li = tz->get_info(std::chrono::local_days{std::chrono::year{2020}/1/1});
std::cout << li.result << '\n'; // unique(0)
}