如何设置时区(UTC)UIDatePicker?

时间:2013-06-06 04:27:31

标签: ios6 uidatepicker

我想将时区设置为(-12:00) - (+12:00)到(-23:45) - (+ 23:45)

+ (NSArray *)timeZoneList {
  NSMutable *list = [[NSMustableArry alloc]init];
  for(int n = -(23 * 60+45); n<= 23*60+45; n+=15; {
    NSString * timeZoneName = @"UTC ";
    NSString *sign;
    if (n==0) sign = @"+-";
    else if(n<0) sign = @"-";
    else sign = @"+";
    timeZoneName = [timeZoneName stringByAppendinfFormat:@"%@ %.2d:%.2d",sign,abs(n/60),abs(n%60)];

    NSTimeZone *timeZone = [NSTimeZone timeZoneForSecondsFromGMT:n*60];
    [list addObject:[NSArray arryWithObjects:timeZoneName,timeZone,nil]];
  }
  return [list copy];
}

我发现上面有一个问题(-18:15) - (+18:15)。

我该怎么办?请指教。

0 个答案:

没有答案