我在哪里可以获得timeZoneWithAbbreviation的缩写列表?

时间:2010-05-23 15:19:57

标签: iphone

我想使用以下API进行时区计算:

NSTimeZone *some_time_zone = [NSTimeZone timeZoneWithAbbreviation:name];

但是,我不知道在哪里可以找到受支持的abbreviation名称列表。例如,Siena Italy的时区的name是什么?

3 个答案:

答案 0 :(得分:60)

代码

NSLog(@"timezones: %@", [NSTimeZone abbreviationDictionary]);

输出

timezones: {
    ADT = "America/Halifax";
    AKDT = "America/Juneau";
    AKST = "America/Juneau";
    ART = "America/Argentina/Buenos_Aires";
    AST = "America/Halifax";
    BDT = "Asia/Dhaka";
    BRST = "America/Sao_Paulo";
    BRT = "America/Sao_Paulo";
    BST = "Europe/London";
    CAT = "Africa/Harare";
    CDT = "America/Chicago";
    CEST = "Europe/Paris";
    CET = "Europe/Paris";
    CLST = "America/Santiago";
    CLT = "America/Santiago";
    COT = "America/Bogota";
    CST = "America/Chicago";
    EAT = "Africa/Addis_Ababa";
    EDT = "America/New_York";
    EEST = "Europe/Istanbul";
    EET = "Europe/Istanbul";
    EST = "America/New_York";
    GMT = GMT;
    GST = "Asia/Dubai";
    HKT = "Asia/Hong_Kong";
    HST = "Pacific/Honolulu";
    ICT = "Asia/Bangkok";
    IRST = "Asia/Tehran";
    IST = "Asia/Calcutta";
    JST = "Asia/Tokyo";
    KST = "Asia/Seoul";
    MDT = "America/Denver";
    MSD = "Europe/Moscow";
    MSK = "Europe/Moscow";
    MST = "America/Denver";
    NZDT = "Pacific/Auckland";
    NZST = "Pacific/Auckland";
    PDT = "America/Los_Angeles";
    PET = "America/Lima";
    PHT = "Asia/Manila";
    PKT = "Asia/Karachi";
    PST = "America/Los_Angeles";
    SGT = "Asia/Singapore";
    UTC = UTC;
    WAT = "Africa/Lagos";
    WEST = "Europe/Lisbon";
    WET = "Europe/Lisbon";
    WIT = "Asia/Jakarta";
}

答案 1 :(得分:31)

尝试[NSTimeZone abbreviationDictionary][NSTimeZone knownTimeZoneNames]

答案 2 :(得分:1)

Swift 3.0:

print("\(NSTimeZone.abbreviationDictionary)")