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
maint-2.0.2
C Robert 2009-08-20 17:50:37 +00:00
parent 51b2141369
commit 855e40b9c4
3 changed files with 17 additions and 54 deletions

View File

@ -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 <crobert@inverse.ca>

View File

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

View File

@ -21,7 +21,6 @@
#import <Foundation/NSValue.h>
#import <Foundation/NSCalendarDate.h>
#import <Foundation/NSUserDefaults.h>
#import <NGObjWeb/WOContext.h>
#import <NGObjWeb/WORequest.h>
@ -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 */