From c6201a01c6b86f4b611744dc0994b2a947b6ce60 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 5 Sep 2006 18:42:18 +0000 Subject: [PATCH] Monotone-Parent: 91b936a7c3b51400c8170802ad0c722be8b8553b Monotone-Revision: 6d9008be8a9f9eeb652c345572bad88c284033f6 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2006-09-05T18:42:18 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 +++ UI/SOGoUI/UIxComponent.h | 2 +- UI/SOGoUI/UIxComponent.m | 57 +++++++++++++++++++++++----------------- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7687eb9f..144699c61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-09-05 Wolfgang Sourdeau + * UI/SOGoUI/UIxComponent.m ([UIxComponent -selectedDate]): add the + user's timezone abbreviation to the date string passed as parameter to + NSCalendarDate to generate an accurate date instance. + * UI/WebServerResources/UIxAppointmentEditor.js: convert the form's time values to integers before comparing them. diff --git a/UI/SOGoUI/UIxComponent.h b/UI/SOGoUI/UIxComponent.h index bfcf238f5..f4b07d985 100644 --- a/UI/SOGoUI/UIxComponent.h +++ b/UI/SOGoUI/UIxComponent.h @@ -38,6 +38,7 @@ { NSMutableDictionary *queryParameters; NSTimeZone *viewTimeZone; + NSCalendarDate *selectedDate; } - (NSString *)queryParameterForKey:(NSString *)_key; @@ -65,7 +66,6 @@ - (NSTimeZone *)backendTimeZone; - (NSCalendarDate *)selectedDate; - (NSString *)dateStringForDate:(NSCalendarDate *)_date; -- (NSCalendarDate *)dateForDateString:(NSString *)_dateString; - (BOOL) hideFrame; diff --git a/UI/SOGoUI/UIxComponent.m b/UI/SOGoUI/UIxComponent.m index 50fc0e554..b9e8aa38b 100644 --- a/UI/SOGoUI/UIxComponent.m +++ b/UI/SOGoUI/UIxComponent.m @@ -114,6 +114,7 @@ static BOOL uixDebugEnabled = NO; if ((self = [super init])) { viewTimeZone = nil; + selectedDate = nil; } return self; @@ -124,6 +125,8 @@ static BOOL uixDebugEnabled = NO; [self->queryParameters release]; if (viewTimeZone) [viewTimeZone release]; + if (selectedDate) + [selectedDate release]; [super dealloc]; } @@ -341,27 +344,38 @@ static BOOL uixDebugEnabled = NO; return GMT; } -- (NSCalendarDate *)selectedDate { - NSString *s; +- (NSCalendarDate *) selectedDate +{ + NSString *s, *dateString; NSCalendarDate *cdate; + unsigned hour, minute; - s = [self queryParameterForKey:@"day"]; - cdate = ([s length] > 0) - ? [self dateForDateString:s] - : [NSCalendarDate date]; - [cdate setTimeZone:[self viewTimeZone]]; - s = [self queryParameterForKey:@"hm"]; - if([s length] == 4) { - unsigned hour, minute; - - hour = [[s substringToIndex:2] unsignedIntValue]; - minute = [[s substringFromIndex:2] unsignedIntValue]; - cdate = [cdate hour:hour minute:minute]; - } - else { - cdate = [cdate hour:12 minute:0]; - } - return cdate; + if (!selectedDate) + { + s = [self queryParameterForKey: @"day"]; + if ([s length] > 0) + { + dateString = [s stringByAppendingFormat: @" %@", + [[self viewTimeZone] abbreviation]]; + cdate = [NSCalendarDate dateWithString: dateString + calendarFormat: @"%Y%m%d %Z"]; + } + else + cdate = [NSCalendarDate date]; + s = [self queryParameterForKey: @"hm"]; + if ([s length] == 4) + { + hour = [[s substringToIndex: 2] unsignedIntValue]; + minute = [[s substringFromIndex: 2] unsignedIntValue]; + selectedDate = [cdate hour: hour minute: minute]; + } + else + selectedDate = [cdate hour: 12 minute: 0]; + + [selectedDate retain]; + } + + return selectedDate; } - (NSString *)dateStringForDate:(NSCalendarDate *)_date { @@ -369,11 +383,6 @@ static BOOL uixDebugEnabled = NO; return [_date descriptionWithCalendarFormat:@"%Y%m%d"]; } -- (NSCalendarDate *)dateForDateString:(NSString *)_dateString { - return [NSCalendarDate dateWithString:_dateString - calendarFormat:@"%Y%m%d"]; -} - - (BOOL) hideFrame { return ([[self queryParameterForKey: @"noframe"] boolValue]);