From 855e40b9c48975cd41360f86380bff49af3dd952 Mon Sep 17 00:00:00 2001 From: C Robert Date: Thu, 20 Aug 2009 17:50:37 +0000 Subject: [PATCH] Reversed Mantis 1911 Monotone-Parent: 8ca5aace55726ddec16532b1c35cb58a10926682 Monotone-Revision: 703ef021864a30cc204316cf7c457d1e1e3a520e Monotone-Author: crobert@inverse.ca Monotone-Date: 2009-08-20T17:50:37 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 1 + UI/Scheduler/UIxDatePicker.h | 3 -- UI/Scheduler/UIxDatePicker.m | 67 +++++++++--------------------------- 3 files changed, 17 insertions(+), 54 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea7792c07..b3a862bf2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,7 @@ Mantis 2040. * UI/Scheduler/UIxDatePicker.m: Fix to use user-defined format, if any. Mantis 1911. + * UI/Scheduler/UIxDatePicker.m: Removed changes from 1911: too many issues. 2009-08-19 Cyril Robert diff --git a/UI/Scheduler/UIxDatePicker.h b/UI/Scheduler/UIxDatePicker.h index b7746cf30..dcfd2cf46 100644 --- a/UI/Scheduler/UIxDatePicker.h +++ b/UI/Scheduler/UIxDatePicker.h @@ -35,15 +35,12 @@ id year; NSString *label; BOOL isDisabled; - NSString *format; - NSString *jsFormat; } - (NSString *) dateID; - (NSString *) dateFormat; - (NSString *) jsDateFormat; - (BOOL) useISOFormats; -- (void) setupFormat; @end #endif /* UIXDATEPICKER_H */ diff --git a/UI/Scheduler/UIxDatePicker.m b/UI/Scheduler/UIxDatePicker.m index bea955813..d74d4c1a5 100644 --- a/UI/Scheduler/UIxDatePicker.m +++ b/UI/Scheduler/UIxDatePicker.m @@ -21,7 +21,6 @@ #import #import -#import #import #import @@ -36,8 +35,6 @@ if ((self = [super init])) { isDisabled = NO; - format = nil; - jsFormat = nil; } return self; @@ -113,63 +110,31 @@ - (NSString *) formattedDateString { - NSMutableString *buf; - NSString *_day, *_month, *_year, *_syear; + char buf[22]; - if (!format) - [self setupFormat]; - - _day = [NSString stringWithFormat: @"%02d", [[self day] intValue]]; - _month = [NSString stringWithFormat: @"%02d", [[self month] intValue]]; - _year = [NSString stringWithFormat: @"%04d", [[self year] intValue]]; - _syear = [NSString stringWithFormat: @"%02d", [[self year] intValue] % 100]; - - buf = [NSMutableString stringWithString: jsFormat]; - [buf replaceString: @"dd" withString: _day]; - [buf replaceString: @"mm" withString: _month]; - [buf replaceString: @"yyyy" withString: _year]; - [buf replaceString: @"yy" withString: _syear]; - - return buf; + if ([self useISOFormats]) { + sprintf(buf, "%04d-%02d-%02d", + [[self year] intValue], + [[self month] intValue], + [[self day] intValue]); + } + else { + sprintf(buf, "%02d/%02d/%04d", + [[self day] intValue], + [[self month] intValue], + [[self year] intValue]); + } + return [NSString stringWithCString:buf]; } - (NSString *) dateFormat { - if (!format) - [self setupFormat]; - return format; + return [self useISOFormats] ? @"%Y-%m-%d" : @"%d/%m/%Y"; } - (NSString *) jsDateFormat { - if (!format) - [self setupFormat]; - return jsFormat; -} - -- (void) setupFormat -{ - NSUserDefaults *ud; - NSMutableString *tmp; - - ud = [[[self context] activeUser] userDefaults]; - tmp = [NSMutableString stringWithString: - [ud stringForKey: @"ShortDateFormat"]]; - if (!tmp) - { - if ([self useISOFormats]) - tmp = [NSMutableString stringWithString: @"%Y-%m-%d"]; - else - tmp = [NSMutableString stringWithString: @"%d/%m/%Y"]; - } - - format = [NSString stringWithString: tmp]; - - [tmp replaceString: @"%d" withString: @"dd"]; - [tmp replaceString: @"%m" withString: @"mm"]; - [tmp replaceString: @"%Y" withString: @"yyyy"]; - [tmp replaceString: @"%y" withString: @"yy"]; - jsFormat = [NSString stringWithString: tmp]; + return [self useISOFormats] ? @"yyyy-mm-dd" : @"dd/mm/yyyy"; } /* action */