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 */