(web) Fix "last day of the month" repeat rule
parent
5e5e52e3f1
commit
491e090fb4
|
@ -126,7 +126,29 @@
|
|||
if ([[rule byDay] length])
|
||||
[repeat setObject: [[rule byDayMask] asRuleArray] forKey: @"days"];
|
||||
if ([[rule byMonthDay] count])
|
||||
[repeat setObject: [rule byMonthDay] forKey: @"monthdays"];
|
||||
{
|
||||
NSMutableArray *byMonthDay = [NSMutableArray arrayWithArray: [rule byMonthDay]];
|
||||
NSMutableArray *byDay = [NSMutableArray array];
|
||||
NSInteger i, count;
|
||||
count = [byMonthDay count];
|
||||
for (i = count - 1; i >= 0; i--)
|
||||
{
|
||||
NSString *day = [byMonthDay objectAtIndex: i];
|
||||
if ([day intValue] < 0)
|
||||
{
|
||||
// Relative BYMONTHDAY mask are moved to the "days" array
|
||||
[byDay addObject: [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
@"relative", @"day",
|
||||
day, @"occurrence",
|
||||
nil]];
|
||||
[byMonthDay removeObjectAtIndex: i];
|
||||
}
|
||||
}
|
||||
if ([byMonthDay count])
|
||||
[repeat setObject: byMonthDay forKey: @"monthdays"];
|
||||
if ([byDay count])
|
||||
[repeat setObject: byDay forKey: @"days"];
|
||||
}
|
||||
if ([[rule byMonth] count])
|
||||
[repeat setObject: [rule byMonth] forKey: @"months"];
|
||||
[data setObject: repeat forKey: @"repeat"];
|
||||
|
|
|
@ -145,22 +145,6 @@
|
|||
return text;
|
||||
}
|
||||
|
||||
- (NSString *) idForWeekDay
|
||||
{
|
||||
static NSArray *shortWeekDaysList = nil;
|
||||
NSString *id;
|
||||
|
||||
if (!shortWeekDaysList)
|
||||
{
|
||||
shortWeekDaysList = [locale objectForKey: NSShortWeekDayNameArray];
|
||||
[shortWeekDaysList retain];
|
||||
}
|
||||
|
||||
id = [NSString stringWithFormat: @"weekDay%i", (int)[shortWeekDaysList indexOfObject: item]];
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
- (NSString *) labelForWeekDay
|
||||
{
|
||||
return item;
|
||||
|
@ -197,7 +181,7 @@
|
|||
|
||||
i = [[self monthlyDayList] indexOfObject: item];
|
||||
if (i % 7 != i)
|
||||
return @"";
|
||||
return @"relative";
|
||||
else
|
||||
return iCalWeekDayString[i];
|
||||
}
|
||||
|
|
|
@ -1171,7 +1171,7 @@
|
|||
|
||||
// Update recurrence definition depending on selections
|
||||
if (this.hasCustomRepeat()) {
|
||||
if (this.repeat.frequency == 'monthly' && this.repeat.month.type && this.repeat.month.type == 'byday' ||
|
||||
if (this.repeat.frequency == 'monthly' && this.repeat.month.type && this.repeat.month.type == 'byday' && this.repeat.month.day != 'relative' ||
|
||||
this.repeat.frequency == 'yearly' && this.repeat.year.byday) {
|
||||
// BYDAY mask for a monthly or yearly recurrence
|
||||
delete component.repeat.monthdays;
|
||||
|
@ -1181,6 +1181,8 @@
|
|||
this.repeat.month.type) {
|
||||
// montly recurrence by month days or yearly by month
|
||||
delete component.repeat.days;
|
||||
if (this.repeat.month.day == 'relative')
|
||||
component.repeat.monthdays = [this.repeat.month.occurrence];
|
||||
}
|
||||
}
|
||||
else if (this.repeat.frequency && this.repeat.frequency != 'never') {
|
||||
|
|
Loading…
Reference in New Issue