0
當我運行下面的PST和AKST時區從不運行這段代碼......上述這些問題都完美運行:PST和農業知識與科技時區錯誤
NSTimeZone *pacificTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"PST"];
NSTimeZone *alaskaTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"AKST"];
但是這些沒有一個是運行:
}else if ([local isEqual: pacificTimeZone]) {
NSLog(@"Pacific");
} else if ([local isEqual: alaskaTimeZone]) {
NSLog(@"Alaska");
有什麼建議嗎?
NSTimeZone *local = [NSTimeZone localTimeZone];
NSTimeZone *centralTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"CST"];
NSTimeZone *easternTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"EST"];
NSTimeZone *mountainTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"MST"];
NSTimeZone *pacificTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"PST"];
NSTimeZone *alaskaTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"AKST"];
NSTimeZone *honoluluTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"HST"];
NSLog(@"LOCAL TIME ZONE: %@", local);
NSLog(@"CST TIME %@", centralTimeZone);
NSLog(@"EST TIME %@", easternTimeZone);
NSLog(@"MST TIME %@", mountainTimeZone);
NSLog(@"PST TIME %@", pacificTimeZone);
NSLog(@"AKST TIME %@", alaskaTimeZone);
NSLog(@"HST TIME %@", honoluluTimeZone);
if ([local isEqual: centralTimeZone])
{
NSLog(@"Central");
} else if ([local isEqual: easternTimeZone]) {
NSLog(@"Eastern");
} else if ([local isEqual: mountainTimeZone]) {
NSLog(@"Mountain");
}else if ([local isEqual: pacificTimeZone]) {
NSLog(@"Pacific");
} else if ([local isEqual: alaskaTimeZone]) {
NSLog(@"Alaska");
} else if ([local isEqual: honoluluTimeZone]) {
NSLog(@"Honolulu");
}
謝謝!
夏威夷及其太平洋/火奴魯魯 – rgreso 2016-10-20 10:11:25
@rgreso - 是的,你是正確的。編輯。謝謝。 – 2016-10-20 19:57:28