iOS 6.1.3 でいくつかのテストを実行しました。これが私が得たものです:
私は午後 1 時 (太平洋夏時間、GMT-7) にシアトルにいます。私が作成したNSDate
:
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *dateComponents = [[NSDateComponents alloc] init];
// 2013-08-31 @ 12:00:00 (noon)
dateComponents.year = 2013;
dateComponents.month = 8;
dateComponents.day = 31;
dateComponents.hour = 12;
dateComponents.minute = 0;
dateComponents.second = 0;
NSDate *fireDate = [gregorianCalendar dateFromComponents:dateComponents];
今私が持っています
fireDate = 2013-08-31 19:00:00 +0000 (2013-08-31 12:00:00 -0700)
次に、通知を作成してスケジュールしました。
notification1 = [[UILocalNotification alloc] init];
notification1.fireDate = fireDate;
// notification1.timeZone is nil by default
NSLog(@"%@", notification1);
notification2 = [[UILocalNotification alloc] init];
notification2.fireDate = fireDate;
notification2.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"];
NSLog(@"%@", notification2);
notification3 = [[UILocalNotification alloc] init];
notification3.fireDate = fireDate;
notification3.timeZone = [NSTimeZone defaultTimeZone];
NSLog(@"%@", notification3);
シアトル (太平洋夏時間、GMT-7) で作成された通知のログ:
notification1:
fire date = Saturday, August 31, 2013, 12:00:00 PM Pacific Daylight Time,
time zone = (null),
next fire date = Saturday, August 31, 2013, 12:00:00 PM Pacific Daylight Time
notification2:
fire date = Saturday, August 31, 2013, 7:00:00 PM GMT,
time zone = GMT (GMT) offset 0,
next fire date = Saturday, August 31, 2013, 7:00:00 PM Pacific Daylight Time
notification3:
fire date = Saturday, August 31, 2013, 12:00:00 PM Pacific Daylight Time,
time zone = US/Pacific (PDT) offset -25200 (Daylight),
next fire date = Saturday, August 31, 2013, 12:00:00 PM Pacific Daylight Time
電話のタイムゾーンをシカゴに変更しました。現在は午後 3 時 (中央夏時間、GMT-5) です。
通知のログ、シカゴ (中央夏時間、GMT-5)
notification1:
fire date = Saturday, August 31, 2013, 2:00:00 PM Central Daylight Time,
time zone = (null),
next fire date = Saturday, August 31, 2013, 2:00:00 PM Central Daylight Time
notification2:
fire date = Saturday, August 31, 2013, 7:00:00 PM GMT,
time zone = GMT (GMT) offset 0,
next fire date = Saturday, August 31, 2013, 7:00:00 PM Central Daylight Time
notification3:
fire date = Saturday, August 31, 2013, 12:00:00 PM Pacific Daylight Time,
time zone = US/Pacific (PDT) offset -25200 (Daylight),
next fire date = Saturday, August 31, 2013, 12:00:00 PM Central Daylight Time
結論:
- UILocalNotification
timeZone
が nil の場合、起動日は時間内に固定されます。つまり、通知は 12:00PM GMT-7、2:00PM GMT-5、または 7:00 GMT に発生します。
- UILocalNotification
timeZone
が GMT に設定されている場合、起動日は GMT 時間で計算され、ユーザーが別のタイム ゾーンに移動すると自動更新されます。この例では、時刻 12:00 GMT-7 が 19:00 GMT に変換され、通知は 19:00 現地時間に設定され、タイム ゾーン (19:00 GMT、19:00 GMT-5 または19:00 GMT-7)。
- UILocalNotification
timeZone
がローカル タイム ゾーン (太平洋夏時間、GMT-7) に設定されている場合、起動日はローカル タイムに対して計算され、ユーザーが別のタイム ゾーンに移動すると自動更新されます。この例では、時間は 12:00 GMT-7 だったので、タイムゾーンに関係なく (12:00 GMT、12:00 GMT-5、または 12:00 GMT- 7)。