Share via


tzdb 구조체

표준 시간대 데이터베이스의 복사본을 나타냅니다.

구문

struct tzdb; // C++20

설명

IANA(인터넷 할당 번호 기관) 표준 시간대 데이터베이스의 복사본을 나타냅니다. 데이터베이스에는 각 표준 시간대 및 현지 시간 조정 기록에 대한 정보가 포함됩니다. 데이터베이스에 대한 자세한 내용은 표준 시간대 데이터베이스를 참조하세요.

멤버

멤버 설명
leap_seconds 정렬된 vector<leap_second>. A leap_second 는 과거에 윤초가 추가된 시점의 기록을 제공합니다.
links 정렬된 vector<time_zone_link>. time_zone_link 지정된 표준 시간대의 대체 이름을 제공합니다.
version std::string 데이터베이스 버전이 포함된 항목입니다.
zones 정렬된 vector<time_zone>. A time_zone 에는 특정 영역에 대한 표준 시간대 규칙의 전체 기록이 있습니다.

이러한 멤버를 사용하는 방법에 대한 예제는 이 항목의 끝부분에 linkszones 있는 예제: leap_seconds

멤버 함수

이름 설명
current_zone 현지 표준 시간대를 가져옵니다.
locate_zone 지정된 표준 시간대를 가져옵니다.

current_zone

컴퓨터의 현지 표준 시간대를 가져옵니다.

time_zone* current_zone() const; // C++20

반환 값

컴퓨터의 time_zone 현지 표준 시간대를 나타내는 포인터입니다.

예: current_zone

이 예제에서는 현재 표준 시간대를 가져오는 방법을 보여 줍니다.

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
    auto& db = get_tzdb();
    std::cout << "Current zone: " << db.current_zone()->name();
    
    return 0;
}
Current zone: America/Los_Angeles

locate_zone

지정된 표준 시간대를 가져옵니다.

const time_zone* locate_zone(string_view name) const;

예: locate_zone

이 예제에서는 이름으로 표준 시간대를 가져오는 방법을 보여 줍니다.

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
    auto& db = get_tzdb();
    std::cout << "Locate zone : " << db.locate_zone("America/New_York")->name() << "\n";
    
    return 0;
}
Locate zone : America/New_York

이 예제에서는 다양한 tzdb 데이터 멤버를 사용하는 방법을 보여 줍니다.

// compile using: /std:c++latest
#include <iostream>
#include <chrono>

using namespace std::chrono;

int main()
{
    std::cout << "Leap seconds:\n";
    std::for_each(db.leap_seconds.begin(), db.leap_seconds.end(),
        [](const leap_second& ls)
        {
            std::cout << ls.date() << "\n";
        });

    std::cout << "Links:\n";
    std::for_each(db.links.begin(), db.links.end(),
        [](const time_zone_link& l)
        {
            std::cout << "Name: " << l.name() << "\t\tTarget:" << l.target() << '\n';
        });

    std::cout << "\nTime Zone descriptions:\n";
    std::for_each(db.zones.begin(), db.zones.end(),
        [](const time_zone& z)
        {
            std::cout << "Zone: " << z.name() << "\n";
        });
    
    return 0;
}
Leap seconds:
1972-07-01 00:00:00
1973-01-01 00:00:00
1974-01-01 00:00:00
...
Links:
Name: ACT               Target:Australia/Darwin
Name: AET               Target:Australia/Sydney
Name: AGT               Target:America/Buenos_Aires
Name: ART               Target:Africa/Cairo
...
Time Zone descriptions:
Zone: Africa/Abidjan
Zone: Africa/Accra
Zone: Africa/Addis_Ababa
...

요구 사항

헤더<chrono>:

네임스페이스:std::chrono

컴파일러 옵션:/std:c++latest

참고 항목

<chrono>
tzdb_list
time_zone_link
헤더 파일 참조