From 504a0855f8863d324c021cc55f28caec234c1ca7 Mon Sep 17 00:00:00 2001 From: znek Date: Wed, 26 Jan 2005 16:42:40 +0000 Subject: [PATCH] Fixed SOGo Bug #1136 git-svn-id: http://svn.opengroupware.org/SOGo/trunk@496 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOGo/UI/SOGoUI/ChangeLog | 7 +++ SOGo/UI/SOGoUI/SOGoDateFormatter.h | 3 ++ SOGo/UI/SOGoUI/SOGoDateFormatter.m | 24 ++++++++-- SOGo/UI/SOGoUI/Version | 2 +- SOGo/UI/Scheduler/ChangeLog | 8 +++- SOGo/UI/Scheduler/UIxDatePicker.m | 77 +++++++++++++++++++++++------- SOGo/UI/Scheduler/Version | 2 +- 7 files changed, 101 insertions(+), 22 deletions(-) diff --git a/SOGo/UI/SOGoUI/ChangeLog b/SOGo/UI/SOGoUI/ChangeLog index 3a950e3d..e782f8c4 100644 --- a/SOGo/UI/SOGoUI/ChangeLog +++ b/SOGo/UI/SOGoUI/ChangeLog @@ -1,3 +1,10 @@ +2005-01-26 Marcus Mueller + + * SOGoDateFormatter.[hm]: new method -setFrenchDateFormat: to override + the default ISO format. This will be chosen depending on locale + automatically. The full description uses this setting when generating + the appropriate part of the description. (v0.9.23) + 2004-12-17 Marcus Mueller * SOGoAptFormatter.m: remove "appointment" prefix from tooltips diff --git a/SOGo/UI/SOGoUI/SOGoDateFormatter.h b/SOGo/UI/SOGoUI/SOGoDateFormatter.h index 89f038c6..15836d69 100644 --- a/SOGo/UI/SOGoUI/SOGoDateFormatter.h +++ b/SOGo/UI/SOGoUI/SOGoDateFormatter.h @@ -30,11 +30,14 @@ { NSDictionary *locale; SEL formatAction; + SEL auxFormatAction; } - (id)initWithLocale:(NSDictionary *)_locale; - (void)setISODateFormat; +- (void)setFrenchDateFormat; + - (void)setFullWeekdayNameAndDetails; - (NSString *)stringForObjectValue:(id)_obj; diff --git a/SOGo/UI/SOGoUI/SOGoDateFormatter.m b/SOGo/UI/SOGoUI/SOGoDateFormatter.m index cf955455..e5cf1957 100644 --- a/SOGo/UI/SOGoUI/SOGoDateFormatter.m +++ b/SOGo/UI/SOGoUI/SOGoDateFormatter.m @@ -37,7 +37,12 @@ - (id)initWithLocale:(NSDictionary *)_locale { if ((self = [super init])) { self->locale = [_locale retain]; - [self setISODateFormat]; + if ([[self->locale objectForKey:@"NSLocaleCode"] isEqualToString:@"fr"]) { + [self setFrenchDateFormat]; + } + else { + [self setISODateFormat]; + } } return self; } @@ -53,8 +58,13 @@ self->formatAction = @selector(isoDateFormatForDate:); } +- (void)setFrenchDateFormat { + self->formatAction = @selector(frenchDateFormatForDate:); +} + - (void)setFullWeekdayNameAndDetails { - self->formatAction = @selector(fullWeekdayNameAndDetailsForDate:); + self->auxFormatAction = self->formatAction; + self->formatAction = @selector(fullWeekdayNameAndDetailsForDate:); } /* operation */ @@ -96,13 +106,21 @@ [_date dayOfMonth]]; } +- (NSString *)frenchDateFormatForDate:(NSCalendarDate *)_date { + return [NSString stringWithFormat:@"%02d/%02d/%04d", + [_date dayOfMonth], + [_date monthOfYear], + [_date yearOfCommonEra]]; +} + - (NSString *)fullWeekdayNameAndDetailsForDate:(NSCalendarDate *)_date { NSMutableString *desc; desc = [NSMutableString stringWithCapacity:24]; [desc appendString:[self fullDayOfWeek:[_date dayOfWeek]]]; [desc appendString:@", "]; - [desc appendString:[self isoDateFormatForDate:_date]]; + [desc appendString:[self performSelector:self->auxFormatAction + withObject:_date]]; [desc appendString:@" "]; [desc appendFormat:@"%02d:%02d ", [_date hourOfDay], [_date minuteOfHour]]; [desc appendString:[[_date timeZone] abbreviation]]; diff --git a/SOGo/UI/SOGoUI/Version b/SOGo/UI/SOGoUI/Version index dd5eff26..ebab15ba 100644 --- a/SOGo/UI/SOGoUI/Version +++ b/SOGo/UI/SOGoUI/Version @@ -1,5 +1,5 @@ # $Id$ -SUBMINOR_VERSION:=22 +SUBMINOR_VERSION:=23 # v0.9.18 requires NGExtensions v4.5.136 diff --git a/SOGo/UI/Scheduler/ChangeLog b/SOGo/UI/Scheduler/ChangeLog index af7f3750..5de688c4 100644 --- a/SOGo/UI/Scheduler/ChangeLog +++ b/SOGo/UI/Scheduler/ChangeLog @@ -1,4 +1,10 @@ -2004-01-07 Marcus Mueller +2005-01-26 Marcus Mueller + + * UIxDatePicker.m: corrected dateFormats for French locale. The + selection mechanism is pretty hackish and should be more generic. + This fixes SOGo Bug #1136. (v0.9.111) + +2005-01-07 Marcus Mueller * {English/French}.lproj/default.strings: changed encoding from ISO-Latin-1 to UTF-8, which is now the default (v0.9.110) diff --git a/SOGo/UI/Scheduler/UIxDatePicker.m b/SOGo/UI/Scheduler/UIxDatePicker.m index 3f8e9519..57d49c7d 100644 --- a/SOGo/UI/Scheduler/UIxDatePicker.m +++ b/SOGo/UI/Scheduler/UIxDatePicker.m @@ -35,7 +35,8 @@ - (NSString *)dateID; - (NSString *)dateFormat; - +- (NSString *)jsDateFormat; +- (BOOL)useISOFormats; @end #include "common.h" @@ -87,17 +88,64 @@ return self->label; } + +/* formats */ + +- (BOOL)useISOFormats { + WOContext *ctx; + NSNumber *useISOFormats; + + ctx = [self context]; + useISOFormats = [ctx valueForKey:@"useISOFormats"]; + if (!useISOFormats) { + NSArray *languages = [ctx resourceLookupLanguages]; + if (languages && [languages count] > 0) { + if ([[languages objectAtIndex:0] isEqualToString:@"French"]) { + useISOFormats = [NSNumber numberWithBool:NO]; + } + } + if (!useISOFormats) + useISOFormats = [NSNumber numberWithBool:YES]; + [ctx takeValue:useISOFormats forKey:@"useISOFormats"]; + } + return [useISOFormats boolValue]; +} - (NSString *)formattedDateString { + if ([self useISOFormats]) { return [NSString stringWithFormat:@"%d-%02d-%02d", - [[self year] intValue], - [[self month] intValue], - [[self day] intValue]]; + [[self year] intValue], + [[self month] intValue], + [[self day] intValue]]; + } + else { + return [NSString stringWithFormat:@"%02d/%02d/%04d", + [[self day] intValue], + [[self month] intValue], + [[self year] intValue]]; + } } - (NSString *)dateFormat { - return @"yyyy-mm-dd"; + if ([self useISOFormats]) { + return @"%Y-%m-%d"; + } + else { + return @"%d/%m/%Y"; + } +} + +- (NSString *)jsDateFormat { + if ([self useISOFormats]) { + return @"yyyy-mm-dd"; + } + else { + return @"dd/mm/yyyy"; + } } + +/* URLs */ + - (NSString *)calendarPageURL { WOResourceManager *rm; WOContext *ctx; @@ -108,22 +156,18 @@ if (rm == nil) [self warnWithFormat:@"missing resource manager!"]; - /* lookup languages */ - - ctx = [self context]; + ctx = [self context]; #if 0 - languages = [ctx hasSession] - ? [[ctx session] languages] - : [[ctx request] browserLanguages]; + languages = [ctx resourceLookupLanguages]; #else #warning !! FIX SoProduct to enable localizable resource, then disable this! languages = nil; #endif return [rm urlForResourceNamed:@"skycalendar.html" - inFramework:nil - languages:languages - request:[ctx request]]; + inFramework:nil + languages:languages + request:[ctx request]]; } /* JavaScript */ @@ -145,7 +189,7 @@ self->dateID, [self calendarPageURL], self->dateID, - [self dateFormat]]; + [self jsDateFormat]]; } /* action */ @@ -160,7 +204,8 @@ return; } - d = [NSCalendarDate dateWithString:dateString calendarFormat:@"%Y-%m-%d"]; + d = [NSCalendarDate dateWithString:dateString + calendarFormat:[self dateFormat]]; if (d == nil) [self warnWithFormat:@"Could not parse dateString: '%@'", dateString]; diff --git a/SOGo/UI/Scheduler/Version b/SOGo/UI/Scheduler/Version index b002074e..55934459 100644 --- a/SOGo/UI/Scheduler/Version +++ b/SOGo/UI/Scheduler/Version @@ -1,6 +1,6 @@ # $Id$ -SUBMINOR_VERSION:=110 +SUBMINOR_VERSION:=111 # v0.9.107 requires WOExtensions v4.5.21 # v0.9.105 requires NGObjWeb v4.5.102 -- 2.39.5