Mantis 1911: Calendrier - support des dates courtes

Monotone-Parent: 7f0d410fd526f1879ea158593030d6d7b46be292
Monotone-Revision: a49dddbcfd99daf939a96a58365d763aadf1efc8

Monotone-Author: crobert@inverse.ca
Monotone-Date: 2009-08-20T14:30:52
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
C Robert 2009-08-20 14:30:52 +00:00
parent 4b4a31796b
commit 5e84df5faa
3 changed files with 56 additions and 16 deletions

View file

@ -4,6 +4,8 @@
return a 409 code when a folder with the same name exists.
* SoObjects/SOGo/SOGoParentFolder.m (hasLocalSubFolderNamed): Added for
Mantis 2040.
* UI/Scheduler/UIxDatePicker.m: Fix to use user-defined format, if any.
Mantis 1911.
2009-08-19 Cyril Robert <crobert@inverse.ca>

View file

@ -35,12 +35,15 @@
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,6 +21,7 @@
#import <Foundation/NSValue.h>
#import <Foundation/NSCalendarDate.h>
#import <Foundation/NSUserDefaults.h>
#import <NGObjWeb/WOContext.h>
#import <NGObjWeb/WORequest.h>
@ -35,6 +36,8 @@
if ((self = [super init]))
{
isDisabled = NO;
format = nil;
jsFormat = nil;
}
return self;
@ -110,31 +113,63 @@
- (NSString *) formattedDateString
{
char buf[22];
NSMutableString *buf;
NSString *_day, *_month, *_year, *_syear;
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];
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;
}
- (NSString *) dateFormat
{
return [self useISOFormats] ? @"%Y-%m-%d" : @"%d/%m/%Y";
if (!format)
[self setupFormat];
return format;
}
- (NSString *) jsDateFormat
{
return [self useISOFormats] ? @"yyyy-mm-dd" : @"dd/mm/yyyy";
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];
}
/* action */