Cleaned up code and fixed the translation of the weekdays in the datepicker
parent
4843c6b6d7
commit
8a17246725
|
@ -1,8 +1,6 @@
|
||||||
/* UIxDatePicker.h - this file is part of SOGo
|
/* UIxDatePicker.h - this file is part of SOGo
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Inverse inc.
|
* Copyright (C) 2009-2014 Inverse inc.
|
||||||
*
|
|
||||||
* Author: Francis Lachapelle <flachapelle@inverse.ca>
|
|
||||||
*
|
*
|
||||||
* This file is free software; you can redistribute it and/or modify
|
* This file is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,23 +1,22 @@
|
||||||
/*
|
/* UIxDatePicker.h - this file is part of SOGo
|
||||||
Copyright (C) 2004-2005 SKYRIX Software AG
|
*
|
||||||
|
* Copyright (C) 2009-2014 Inverse inc.
|
||||||
This file is part of OpenGroupware.org.
|
*
|
||||||
|
* This file is free software; you can redistribute it and/or modify
|
||||||
OGo is free software; you can redistribute it and/or modify it under
|
* it under the terms of the GNU General Public License as published by
|
||||||
the terms of the GNU Lesser General Public License as published by the
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
Free Software Foundation; either version 2, or (at your option) any
|
* any later version.
|
||||||
later version.
|
*
|
||||||
|
* This file is distributed in the hope that it will be useful,
|
||||||
OGo is distributed in the hope that it will be useful, but WITHOUT ANY
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
* GNU General Public License for more details.
|
||||||
License for more details.
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
You should have received a copy of the GNU Lesser General Public
|
* along with this program; see the file COPYING. If not, write to
|
||||||
License along with OGo; see the file COPYING. If not, write to the
|
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
|
* Boston, MA 02111-1307, USA.
|
||||||
02111-1307, USA.
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
#import <Foundation/NSValue.h>
|
#import <Foundation/NSValue.h>
|
||||||
#import <Foundation/NSCalendarDate.h>
|
#import <Foundation/NSCalendarDate.h>
|
||||||
|
@ -38,13 +37,18 @@
|
||||||
{
|
{
|
||||||
if ((self = [super init]))
|
if ((self = [super init]))
|
||||||
{
|
{
|
||||||
|
dateID = nil;
|
||||||
|
day = nil;
|
||||||
|
year = nil;
|
||||||
|
label = nil;
|
||||||
isDisabled = NO;
|
isDisabled = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc {
|
- (void) dealloc
|
||||||
|
{
|
||||||
[self->dateID release];
|
[self->dateID release];
|
||||||
[self->day release];
|
[self->day release];
|
||||||
[self->month release];
|
[self->month release];
|
||||||
|
@ -55,60 +59,79 @@
|
||||||
|
|
||||||
/* Accessors */
|
/* Accessors */
|
||||||
|
|
||||||
- (void)setDateID:(NSString *)_dateID {
|
- (void) setDateID: (NSString *) _dateID
|
||||||
|
{
|
||||||
ASSIGNCOPY(self->dateID, _dateID);
|
ASSIGNCOPY(self->dateID, _dateID);
|
||||||
}
|
}
|
||||||
- (NSString *)dateID {
|
- (NSString *) dateID
|
||||||
|
{
|
||||||
return self->dateID;
|
return self->dateID;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setDay:(id)_day {
|
- (void) setDay: (id) _day
|
||||||
|
{
|
||||||
ASSIGN(self->day, _day);
|
ASSIGN(self->day, _day);
|
||||||
}
|
}
|
||||||
- (id)day {
|
- (id) day
|
||||||
return self->day;
|
{
|
||||||
|
return self->day;
|
||||||
}
|
}
|
||||||
- (void)setMonth:(id)_month {
|
|
||||||
|
- (void) setMonth: (id) _month
|
||||||
|
{
|
||||||
ASSIGN(self->month, _month);
|
ASSIGN(self->month, _month);
|
||||||
}
|
}
|
||||||
- (id)month {
|
- (id) month
|
||||||
return self->month;
|
{
|
||||||
|
return self->month;
|
||||||
}
|
}
|
||||||
- (void)setYear:(id)_year {
|
|
||||||
|
- (void) setYear: (id) _year
|
||||||
|
{
|
||||||
ASSIGN(self->year, _year);
|
ASSIGN(self->year, _year);
|
||||||
}
|
}
|
||||||
- (id)year {
|
- (id) year
|
||||||
return self->year;
|
{
|
||||||
|
return self->year;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setLabel: (NSString *) _label
|
||||||
- (void)setLabel:(NSString *)_label {
|
{
|
||||||
ASSIGNCOPY(self->label, _label);
|
ASSIGNCOPY(self->label, _label);
|
||||||
}
|
}
|
||||||
- (NSString *)label {
|
- (NSString *) label
|
||||||
|
{
|
||||||
return self->label;
|
return self->label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* formats */
|
/* formats */
|
||||||
|
|
||||||
- (BOOL)useISOFormats {
|
- (BOOL) useISOFormats
|
||||||
|
{
|
||||||
|
NSNumber *useISOFormats;
|
||||||
WOContext *ctx;
|
WOContext *ctx;
|
||||||
NSNumber *useISOFormats;
|
|
||||||
|
|
||||||
ctx = [self context];
|
ctx = [self context];
|
||||||
useISOFormats = [ctx valueForKey:@"useISOFormats"];
|
useISOFormats = [ctx valueForKey:@"useISOFormats"];
|
||||||
if (!useISOFormats) {
|
if (!useISOFormats)
|
||||||
NSArray *languages = [ctx resourceLookupLanguages];
|
{
|
||||||
if (languages && [languages count] > 0) {
|
NSArray *languages;
|
||||||
if ([[languages objectAtIndex:0] isEqualToString:@"French"]) {
|
|
||||||
useISOFormats = [NSNumber numberWithBool:NO];
|
languages = [ctx resourceLookupLanguages];
|
||||||
|
if (languages && [languages count] > 0)
|
||||||
|
{
|
||||||
|
if ([[languages objectAtIndex:0] isEqualToString:@"French"])
|
||||||
|
{
|
||||||
|
useISOFormats = [NSNumber numberWithBool:NO];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!useISOFormats)
|
if (!useISOFormats)
|
||||||
useISOFormats = [NSNumber numberWithBool:YES];
|
useISOFormats = [NSNumber numberWithBool: YES];
|
||||||
[ctx takeValue:useISOFormats forKey:@"useISOFormats"];
|
|
||||||
}
|
[ctx takeValue: useISOFormats forKey:@"useISOFormats"];
|
||||||
|
}
|
||||||
|
|
||||||
return [useISOFormats boolValue];
|
return [useISOFormats boolValue];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,17 +139,19 @@
|
||||||
{
|
{
|
||||||
char buf[22];
|
char buf[22];
|
||||||
|
|
||||||
if ([self useISOFormats]) {
|
if ([self useISOFormats])
|
||||||
sprintf(buf, "%04d-%02d-%02d",
|
{
|
||||||
[[self year] intValue],
|
sprintf(buf, "%04d-%02d-%02d",
|
||||||
[[self month] intValue],
|
[[self year] intValue],
|
||||||
[[self day] intValue]);
|
[[self month] intValue],
|
||||||
}
|
[[self day] intValue]);
|
||||||
else {
|
}
|
||||||
sprintf(buf, "%02d/%02d/%04d",
|
else
|
||||||
[[self day] intValue],
|
{
|
||||||
[[self month] intValue],
|
sprintf(buf, "%02d/%02d/%04d",
|
||||||
[[self year] intValue]);
|
[[self day] intValue],
|
||||||
|
[[self month] intValue],
|
||||||
|
[[self year] intValue]);
|
||||||
}
|
}
|
||||||
return [NSString stringWithCString:buf];
|
return [NSString stringWithCString:buf];
|
||||||
}
|
}
|
||||||
|
@ -141,29 +166,30 @@
|
||||||
return [self useISOFormats] ? @"yyyy-mm-dd" : @"dd/mm/yyyy";
|
return [self useISOFormats] ? @"yyyy-mm-dd" : @"dd/mm/yyyy";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* action */
|
|
||||||
|
|
||||||
- (void) takeValuesFromRequest: (WORequest *) _rq
|
- (void) takeValuesFromRequest: (WORequest *) _rq
|
||||||
inContext: (WOContext *)_ctx
|
inContext: (WOContext *) _ctx
|
||||||
{
|
{
|
||||||
NSString *dateString;
|
|
||||||
NSCalendarDate *d;
|
|
||||||
NSInteger dateTZOffset, userTZOffset;
|
NSInteger dateTZOffset, userTZOffset;
|
||||||
NSTimeZone *systemTZ, *userTZ;
|
NSTimeZone *systemTZ, *userTZ;
|
||||||
SOGoUserDefaults *ud;
|
SOGoUserDefaults *ud;
|
||||||
|
NSString *dateString;
|
||||||
|
NSCalendarDate *d;
|
||||||
|
|
||||||
dateString = [_rq formValueForKey:[self dateID]];
|
dateString = [_rq formValueForKey:[self dateID]];
|
||||||
if (dateString == nil) {
|
|
||||||
[self debugWithFormat:@"got no date string!"];
|
if (dateString == nil)
|
||||||
return;
|
{
|
||||||
}
|
[self debugWithFormat:@"got no date string!"];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
d = [NSCalendarDate dateWithString:dateString
|
d = [NSCalendarDate dateWithString: dateString
|
||||||
calendarFormat:[self dateFormat]];
|
calendarFormat: [self dateFormat]];
|
||||||
if (d == nil) {
|
if (!d)
|
||||||
[self warnWithFormat:@"Could not parse dateString: '%@'",
|
{
|
||||||
|
[self warnWithFormat: @"Could not parse dateString: '%@'",
|
||||||
dateString];
|
dateString];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we must adjust the date timezone because "dateWithString:..." uses the
|
/* we must adjust the date timezone because "dateWithString:..." uses the
|
||||||
system timezone, which can be different from the user's. */
|
system timezone, which can be different from the user's. */
|
||||||
|
@ -178,11 +204,11 @@
|
||||||
seconds: (dateTZOffset - userTZOffset)];
|
seconds: (dateTZOffset - userTZOffset)];
|
||||||
[d setTimeZone: userTZ];
|
[d setTimeZone: userTZ];
|
||||||
|
|
||||||
[self setDay: [NSNumber numberWithInt:[d dayOfMonth]]];
|
[self setDay: [NSNumber numberWithInt:[d dayOfMonth]]];
|
||||||
[self setMonth:[NSNumber numberWithInt:[d monthOfYear]]];
|
[self setMonth: [NSNumber numberWithInt:[d monthOfYear]]];
|
||||||
[self setYear: [NSNumber numberWithInt:[d yearOfCommonEra]]];
|
[self setYear: [NSNumber numberWithInt:[d yearOfCommonEra]]];
|
||||||
|
|
||||||
[super takeValuesFromRequest:_rq inContext:_ctx];
|
[super takeValuesFromRequest: _rq inContext: _ctx];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setDisabled: (BOOL) disabled
|
- (void) setDisabled: (BOOL) disabled
|
||||||
|
|
|
@ -1420,7 +1420,7 @@
|
||||||
en: {
|
en: {
|
||||||
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
||||||
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
||||||
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
daysMin: ["a2_Sunday", "a2_Monday", "a2_Tuesday", "a2_Wednesday", "a2_Thursday", "a2_Friday", "a2_Saturday", "a2_Sunday"],
|
||||||
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||||
today: "Today",
|
today: "Today",
|
||||||
|
|
Loading…
Reference in New Issue