]> err.no Git - scalable-opengroupware.org/commitdiff
Fixed SOGo Bug #1136
authorznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 26 Jan 2005 16:42:40 +0000 (16:42 +0000)
committerznek <znek@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Wed, 26 Jan 2005 16:42:40 +0000 (16:42 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@496 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/UI/SOGoUI/ChangeLog
SOGo/UI/SOGoUI/SOGoDateFormatter.h
SOGo/UI/SOGoUI/SOGoDateFormatter.m
SOGo/UI/SOGoUI/Version
SOGo/UI/Scheduler/ChangeLog
SOGo/UI/Scheduler/UIxDatePicker.m
SOGo/UI/Scheduler/Version

index 3a950e3d12e114530cbe42e2d1f27d51cb571933..e782f8c49cdd90eefb2b7ad4371c73f033ad995d 100644 (file)
@@ -1,3 +1,10 @@
+2005-01-26  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * 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  <znek@mulle-kybernetik.com>
 
        * SOGoAptFormatter.m: remove "appointment" prefix from tooltips
index 89f038c676bcaff1008f9536ead20ea2709d4495..15836d69e0660219a9f74edcdadbf8ee0353e0b9 100644 (file)
 {
     NSDictionary *locale;
     SEL formatAction;
+    SEL auxFormatAction;
 }
 
 - (id)initWithLocale:(NSDictionary *)_locale;
 
 - (void)setISODateFormat;
+- (void)setFrenchDateFormat;
+
 - (void)setFullWeekdayNameAndDetails;
 
 - (NSString *)stringForObjectValue:(id)_obj;
index cf95545501b4ad758476ba05b27bdda264b1eb48..e5cf1957bb8b3ff368e577a41d0838772ca25a64 100644 (file)
 - (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;
 }
   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 */
                   [_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]];
index dd5eff262b3a74eb473420a31961e0d3576ffe48..ebab15badd4ec0f2916a207343636ffcd55b9954 100644 (file)
@@ -1,5 +1,5 @@
 # $Id$
 
-SUBMINOR_VERSION:=22
+SUBMINOR_VERSION:=23
 
 # v0.9.18 requires NGExtensions v4.5.136
index af7f3750edf22402a7dd1e86ae62c58f3d6f91b0..5de688c4b537fa1ea98baa424b10152a32e76dfe 100644 (file)
@@ -1,4 +1,10 @@
-2004-01-07  Marcus Mueller  <znek@mulle-kybernetik.com>
+2005-01-26  Marcus Mueller  <znek@mulle-kybernetik.com>
+
+       * 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  <znek@mulle-kybernetik.com>
 
        * {English/French}.lproj/default.strings: changed encoding from
          ISO-Latin-1 to UTF-8, which is now the default (v0.9.110)
index 3f8e95193956b63fe4aef9c06438d6393e2ff98d..57d49c7d0569a264c0c387f5ac3fea3f4f05fb56 100644 (file)
@@ -35,7 +35,8 @@
 
 - (NSString *)dateID;
 - (NSString *)dateFormat;
-    
+- (NSString *)jsDateFormat;
+- (BOOL)useISOFormats;
 @end
 
 #include "common.h"
   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;
   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 */
         self->dateID,
         [self calendarPageURL],
         self->dateID,
-        [self dateFormat]];
+        [self jsDateFormat]];
 }
 
 /* action */
     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];
index b002074e2efa6cace1255fe824cec8e73dd196bc..5593445911f4e995850fccb67a19b24c5bcd66b8 100644 (file)
@@ -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