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:
parent
4b4a31796b
commit
5e84df5faa
|
@ -4,6 +4,8 @@
|
||||||
return a 409 code when a folder with the same name exists.
|
return a 409 code when a folder with the same name exists.
|
||||||
* SoObjects/SOGo/SOGoParentFolder.m (hasLocalSubFolderNamed): Added for
|
* SoObjects/SOGo/SOGoParentFolder.m (hasLocalSubFolderNamed): Added for
|
||||||
Mantis 2040.
|
Mantis 2040.
|
||||||
|
* UI/Scheduler/UIxDatePicker.m: Fix to use user-defined format, if any.
|
||||||
|
Mantis 1911.
|
||||||
|
|
||||||
2009-08-19 Cyril Robert <crobert@inverse.ca>
|
2009-08-19 Cyril Robert <crobert@inverse.ca>
|
||||||
|
|
||||||
|
|
|
@ -35,12 +35,15 @@
|
||||||
id year;
|
id year;
|
||||||
NSString *label;
|
NSString *label;
|
||||||
BOOL isDisabled;
|
BOOL isDisabled;
|
||||||
|
NSString *format;
|
||||||
|
NSString *jsFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) dateID;
|
- (NSString *) dateID;
|
||||||
- (NSString *) dateFormat;
|
- (NSString *) dateFormat;
|
||||||
- (NSString *) jsDateFormat;
|
- (NSString *) jsDateFormat;
|
||||||
- (BOOL) useISOFormats;
|
- (BOOL) useISOFormats;
|
||||||
|
- (void) setupFormat;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif /* UIXDATEPICKER_H */
|
#endif /* UIXDATEPICKER_H */
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#import <Foundation/NSValue.h>
|
#import <Foundation/NSValue.h>
|
||||||
#import <Foundation/NSCalendarDate.h>
|
#import <Foundation/NSCalendarDate.h>
|
||||||
|
#import <Foundation/NSUserDefaults.h>
|
||||||
|
|
||||||
#import <NGObjWeb/WOContext.h>
|
#import <NGObjWeb/WOContext.h>
|
||||||
#import <NGObjWeb/WORequest.h>
|
#import <NGObjWeb/WORequest.h>
|
||||||
|
@ -35,6 +36,8 @@
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
isDisabled = NO;
|
isDisabled = NO;
|
||||||
|
format = nil;
|
||||||
|
jsFormat = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
|
@ -110,31 +113,63 @@
|
||||||
|
|
||||||
- (NSString *) formattedDateString
|
- (NSString *) formattedDateString
|
||||||
{
|
{
|
||||||
char buf[22];
|
NSMutableString *buf;
|
||||||
|
NSString *_day, *_month, *_year, *_syear;
|
||||||
|
|
||||||
if ([self useISOFormats]) {
|
if (!format)
|
||||||
sprintf(buf, "%04d-%02d-%02d",
|
[self setupFormat];
|
||||||
[[self year] intValue],
|
|
||||||
[[self month] intValue],
|
_day = [NSString stringWithFormat: @"%02d", [[self day] intValue]];
|
||||||
[[self day] intValue]);
|
_month = [NSString stringWithFormat: @"%02d", [[self month] intValue]];
|
||||||
}
|
_year = [NSString stringWithFormat: @"%04d", [[self year] intValue]];
|
||||||
else {
|
_syear = [NSString stringWithFormat: @"%02d", [[self year] intValue] % 100];
|
||||||
sprintf(buf, "%02d/%02d/%04d",
|
|
||||||
[[self day] intValue],
|
buf = [NSMutableString stringWithString: jsFormat];
|
||||||
[[self month] intValue],
|
[buf replaceString: @"dd" withString: _day];
|
||||||
[[self year] intValue]);
|
[buf replaceString: @"mm" withString: _month];
|
||||||
}
|
[buf replaceString: @"yyyy" withString: _year];
|
||||||
return [NSString stringWithCString:buf];
|
[buf replaceString: @"yy" withString: _syear];
|
||||||
|
|
||||||
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) dateFormat
|
- (NSString *) dateFormat
|
||||||
{
|
{
|
||||||
return [self useISOFormats] ? @"%Y-%m-%d" : @"%d/%m/%Y";
|
if (!format)
|
||||||
|
[self setupFormat];
|
||||||
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) jsDateFormat
|
- (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 */
|
/* action */
|
||||||
|
|
Loading…
Reference in a new issue