Monotone-Parent: 006880968b9bb9ad30735d48958c2b1ad1396bce
Monotone-Revision: 09e07a1c8e00beee8c2f4bdeebb726ac5f57b9e9 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-10-18T23:12:04 Monotone-Branch: ca.inverse.sogomaint-2.0.2
parent
6d8d1b3dd3
commit
6484ed17fe
|
@ -1,3 +1,9 @@
|
||||||
|
2010-10-18 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||||
|
|
||||||
|
* iCalTimeZonePeriod.m (_occurenceForDate:byRRule:): we don't need
|
||||||
|
to deduct the offset from UTC from the resulting date since
|
||||||
|
"tzStart" is already relative to UTC.
|
||||||
|
|
||||||
2010-10-13 Francis Lachapelle <flachapelle@inverse.ca>
|
2010-10-13 Francis Lachapelle <flachapelle@inverse.ca>
|
||||||
|
|
||||||
* NSString+NGCards.m (-vCardSubvaluesWithSeparator): properly
|
* NSString+NGCards.m (-vCardSubvaluesWithSeparator): properly
|
||||||
|
|
|
@ -145,14 +145,13 @@
|
||||||
timeZone: [NSTimeZone timeZoneWithName: @"GMT"]];
|
timeZone: [NSTimeZone timeZoneWithName: @"GMT"]];
|
||||||
tmpDate = [tmpDate addYear: 0 month: ((pos > 0) ? 0 : 1)
|
tmpDate = [tmpDate addYear: 0 month: ((pos > 0) ? 0 : 1)
|
||||||
day: 0 hour: 0 minute: 0
|
day: 0 hour: 0 minute: 0
|
||||||
second: -[self _secondsOfOffset: @"tzoffsetfrom"]];
|
second: 0];
|
||||||
|
|
||||||
dateDayOfWeek = [tmpDate dayOfWeek];
|
|
||||||
|
|
||||||
/* If the day of the time change is "-XSU", we need to determine whether the
|
/* If the day of the time change is "-XSU", we need to determine whether the
|
||||||
first day of next month is in the same week. In practice, as most time
|
first day of next month is in the same week. In practice, as most time
|
||||||
changes occurs on sundays, it will be false only when that first day is a
|
changes occurs on sundays, it will be false only when that first day is a
|
||||||
sunday, but we want to remain algorithmically exact. */
|
sunday, but we want to remain algorithmically exact. */
|
||||||
|
dateDayOfWeek = [tmpDate dayOfWeek];
|
||||||
if (dateDayOfWeek > dayOfWeek && pos < 0)
|
if (dateDayOfWeek > dayOfWeek && pos < 0)
|
||||||
pos++;
|
pos++;
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,47 @@
|
||||||
|
|
||||||
@implementation TestiCalTimeZonePeriod
|
@implementation TestiCalTimeZonePeriod
|
||||||
|
|
||||||
|
- (void) test_occurenceForDate_
|
||||||
|
{
|
||||||
|
NSString *periods[] = { (@"BEGIN:DAYLIGHT\r\n"
|
||||||
|
@"TZOFFSETFROM:-0500\r\n"
|
||||||
|
@"TZOFFSETTO:-0400\r\n"
|
||||||
|
@"TZNAME:EDT\r\n"
|
||||||
|
@"DTSTART:19700308T020000\r\n"
|
||||||
|
@"RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU\r\n"
|
||||||
|
@"END:DAYLIGHT"),
|
||||||
|
(@"BEGIN:STANDARD\r\n"
|
||||||
|
@"TZOFFSETFROM:-0400\r\n"
|
||||||
|
@"TZOFFSETTO:-0500\r\n"
|
||||||
|
@"TZNAME:EST\r\n"
|
||||||
|
@"DTSTART:19701101T020000\r\n"
|
||||||
|
@"RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU\r\n"
|
||||||
|
@"END:STANDARD") };
|
||||||
|
NSString *dateStrings[] = { @"20100314T050000Z", @"20101107T050000Z" };
|
||||||
|
// with TZ=America/Montreal:
|
||||||
|
// date --date="2010-03-14 01:59" +"%s" -> 1268549940
|
||||||
|
// date --date="2010-03-14 02:00" +"%s" -> invalid
|
||||||
|
// date --date="2010-03-14 03:00" +"%s" -> 1268550000
|
||||||
|
// date --date="2010-11-07 01:59" +"%s" -> 1289109540
|
||||||
|
// date --date="2010-11-07 02:00" +"%s" -> 1289113200
|
||||||
|
NSInteger occurrenceSeconds[] = { 1268550000, 1289113200 };
|
||||||
|
NSInteger count, delta;
|
||||||
|
iCalTimeZonePeriod *period;
|
||||||
|
NSCalendarDate *testDate;
|
||||||
|
|
||||||
|
for (count = 0; count < 2; count++)
|
||||||
|
{
|
||||||
|
period = [iCalTimeZonePeriod parseSingleFromSource: periods[count]];
|
||||||
|
testDate = [period occurenceForDate: [dateStrings[count] asCalendarDate]];
|
||||||
|
delta = (NSInteger) [testDate timeIntervalSince1970] - occurrenceSeconds[count];
|
||||||
|
testWithMessage ((NSInteger) [testDate timeIntervalSince1970]
|
||||||
|
== occurrenceSeconds[count],
|
||||||
|
([NSString stringWithFormat:
|
||||||
|
@"test %d: seconds do not match:"
|
||||||
|
@" delta = %d", count, delta]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void) test__occurenceForDate_byRRule_
|
- (void) test__occurenceForDate_byRRule_
|
||||||
{
|
{
|
||||||
/* all rules are happening on 2010-03-14 */
|
/* all rules are happening on 2010-03-14 */
|
||||||
|
|
Loading…
Reference in New Issue