diff --git a/ChangeLog b/ChangeLog index 1c2dcc2e3..d47cf7cb0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2007-10-30 Wolfgang Sourdeau + * UI/Scheduler/UIxCalListingActions.m ([UIxCalListingActions + -eventsListAction]): substitude the start and end date with their + UTC counterpart, taking into account the offset from UTC related + to those dates instead of the current one. This renders + -[UIxCalMainView -userUTCOffset] obsolete because the computings + that occured in javascript are now done server-side. + + * UI/Scheduler/UIxCalMainView.m ([UIxCalMainView -userUTCOffset]): + removed obsolete method. + * SoObjects/Mailer/NSString+Mail.m ([NSString -htmlToText]): new method converting html content to plain text. diff --git a/UI/Scheduler/UIxCalListingActions.m b/UI/Scheduler/UIxCalListingActions.m index 56a608294..0937d932e 100644 --- a/UI/Scheduler/UIxCalListingActions.m +++ b/UI/Scheduler/UIxCalListingActions.m @@ -25,6 +25,7 @@ #import #import #import +#import #import #import @@ -287,6 +288,24 @@ return formattedDate; } +- (NSString *) _adjustedDateForSeconds: (unsigned int) seconds + forAllDay: (BOOL) forAllDay +{ + NSCalendarDate *date; + unsigned int newSeconds, offset; + + date = [NSCalendarDate dateWithTimeIntervalSince1970: seconds]; + [date setTimeZone: userTimeZone]; + + offset = [userTimeZone secondsFromGMTForDate: date]; + if (forAllDay) + newSeconds = seconds + [userTimeZone secondsFromGMT] - offset; + else + newSeconds = seconds + offset; + + return [NSString stringWithFormat: @"%u", newSeconds]; +} + - (WOResponse *) eventsListAction { NSArray *fields, *oldEvent; @@ -309,9 +328,15 @@ newEvent = [NSMutableArray arrayWithArray: oldEvent]; isAllDay = [[oldEvent objectAtIndex: 7] boolValue]; interval = [[oldEvent objectAtIndex: 4] intValue]; + [newEvent replaceObjectAtIndex: 4 + withObject: [self _adjustedDateForSeconds: interval + forAllDay: isAllDay]]; [newEvent addObject: [self _formattedDateForSeconds: interval forAllDay: isAllDay]]; interval = [[oldEvent objectAtIndex: 5] intValue]; + [newEvent replaceObjectAtIndex: 5 + withObject: [self _adjustedDateForSeconds: interval + forAllDay: isAllDay]]; [newEvent addObject: [self _formattedDateForSeconds: interval forAllDay: isAllDay]]; [newEvents addObject: newEvent]; diff --git a/UI/Scheduler/UIxCalMainView.m b/UI/Scheduler/UIxCalMainView.m index a7c0126f0..fdbdd81f7 100644 --- a/UI/Scheduler/UIxCalMainView.m +++ b/UI/Scheduler/UIxCalMainView.m @@ -42,15 +42,6 @@ static NSMutableArray *yearMenuItems = nil; @implementation UIxCalMainView -- (NSString *) userUTCOffset -{ - NSTimeZone *userTZ; - - userTZ = [[context activeUser] timeZone]; - - return [NSString stringWithFormat: @"%d", [userTZ secondsFromGMT]]; -} - - (NSArray *) monthMenuItems { unsigned int count; diff --git a/UI/Templates/SchedulerUI/UIxCalMainView.wox b/UI/Templates/SchedulerUI/UIxCalMainView.wox index 8359c472d..d39e8e7d3 100644 --- a/UI/Templates/SchedulerUI/UIxCalMainView.wox +++ b/UI/Templates/SchedulerUI/UIxCalMainView.wox @@ -8,9 +8,6 @@ xmlns:label="OGo:label" className="UIxPageFrame" title="title"> - diff --git a/UI/WebServerResources/JavascriptAPIExtensions.js b/UI/WebServerResources/JavascriptAPIExtensions.js index 18fe2bd6b..d288fb4b0 100644 --- a/UI/WebServerResources/JavascriptAPIExtensions.js +++ b/UI/WebServerResources/JavascriptAPIExtensions.js @@ -82,14 +82,21 @@ Date.prototype.sogoDayName = function() { Date.prototype.daysUpTo = function(otherDate) { var days = new Array(); - var day1Date = new Date(); - day1Date.setTime(this.getTime()); - day1Date.setHours(0, 0, 0, 0); - var day2Date = new Date(); - day2Date.setTime(otherDate.getTime()); - day2Date.setHours(23, 59, 59, 999); - var day1 = day1Date.getTime(); - var day2 = day2Date.getTime(); + var day1 = this.getTime(); + var day2 = otherDate.getTime(); + if (day1 > day2) { + var tmp = day1; + day1 = day2; + day2 = tmp; + } +// var day1Date = new Date(); +// day1Date.setTime(this.getTime()); +// day1Date.setHours(0, 0, 0, 0); +// var day2Date = new Date(); +// day2Date.setTime(otherDate.getTime()); +// day2Date.setHours(23, 59, 59, 999); +// var day1 = day1Date.getTime(); +// var day2 = day2Date.getTime(); var nbrDays = Math.floor((day2 - day1) / 86400000) + 1; for (var i = 0; i < nbrDays; i++) { diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js index 7fd00f8bf..19e4bce06 100644 --- a/UI/WebServerResources/SchedulerUI.js +++ b/UI/WebServerResources/SchedulerUI.js @@ -617,17 +617,11 @@ function drawCalendarEvent(eventData, sd, ed) { var viewEndDate = ed.asDate(); var startDate = new Date(); + startDate.setTime(eventData[4] * 1000); var endDate = new Date(); - if (eventData[7] == 0) { - startDate.setTime(eventData[4] * 1000 + (1000 * UTCOffset)); - endDate.setTime(eventData[5] * 1000 + (1000 * UTCOffset)); - } - else { - startDate.setTime(eventData[4] * 1000); - endDate.setTime(eventData[5] * 1000); - } + endDate.setTime(eventData[5] * 1000); -// log ("s: " + startDate+ "; e: " + endDate); +// log ("s: " + startDate + "; e: " + endDate); var days = startDate.daysUpTo(endDate);