/*
- Copyright (C) 2004 SKYRIX Software AG
+ Copyright (C) 2004-2005 SKYRIX Software AG
This file is part of OpenGroupware.org.
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include <NGObjWeb/WOComponent.h>
-@class NSString, NSCalendarDate;
+@class NSString;
@interface UIxDatePicker : WOComponent
{
- NSString *dateID;
- id day;
- id month;
- id year;
- NSString *label;
+ NSString *dateID;
+ id day;
+ id month;
+ id year;
+ NSString *label;
}
- (NSString *)dateID;
}
- (void)setDay:(id)_day {
- ASSIGN(self->day, _day);
+ ASSIGN(self->day, _day);
}
- (id)day {
return self->day;
}
- (void)setMonth:(id)_month {
- ASSIGN(self->month, _month);
+ ASSIGN(self->month, _month);
}
- (id)month {
return self->month;
}
- (void)setYear:(id)_year {
- ASSIGN(self->year, _year);
+ ASSIGN(self->year, _year);
}
- (id)year {
return self->year;
return [useISOFormats boolValue];
}
- (NSString *)formattedDateString {
+ char buf[22];
+
if ([self useISOFormats]) {
- return [NSString stringWithFormat:@"%04d-%02d-%02d",
- [[self year] intValue],
- [[self month] intValue],
- [[self day] intValue]];
+ sprintf(buf, "%04d-%02d-%02d",
+ [[self year] intValue],
+ [[self month] intValue],
+ [[self day] intValue]);
}
else {
- return [NSString stringWithFormat:@"%02d/%02d/%04d",
- [[self day] intValue],
- [[self month] intValue],
- [[self year] intValue]];
+ sprintf(buf, "%02d/%02d/%04d",
+ [[self day] intValue],
+ [[self month] intValue],
+ [[self year] intValue]);
}
+ return [NSString stringWithCString:buf];
}
- (NSString *)dateFormat {
- if ([self useISOFormats]) {
- return @"%Y-%m-%d";
- }
- else {
- return @"%d/%m/%Y";
- }
+ return [self useISOFormats] ? @"%Y-%m-%d" : @"%d/%m/%Y";
}
- (NSString *)jsDateFormat {
- if ([self useISOFormats]) {
- return @"yyyy-mm-dd";
- }
- else {
- return @"dd/mm/yyyy";
- }
+ return [self useISOFormats] ? @"yyyy-mm-dd" : @"dd/mm/yyyy";
}
languages = nil;
#endif
- return [rm urlForResourceNamed:@"skycalendar.html"
- inFramework:nil
- languages:languages
- request:[ctx request]];
+ return [rm urlForResourceNamed:@"skycalendar.html" inFramework:nil
+ languages:languages request:[ctx request]];
}
/* JavaScript */
@"var calendar_%@ = new skycalendar(document.getElementById('%@'));\n"
@"calendar_%@.setCalendarPage('%@');\n"
@"calendar_%@.setDateFormat('%@');\n";
-
+
return [NSString stringWithFormat:code,
- self->dateID,
- self->dateID,
- self->dateID,
- [self calendarPageURL],
- self->dateID,
- [self jsDateFormat]];
+ self->dateID,
+ self->dateID,
+ self->dateID,
+ [self calendarPageURL],
+ self->dateID,
+ [self jsDateFormat]];
}
/* action */
d = [NSCalendarDate dateWithString:dateString
calendarFormat:[self dateFormat]];
- if (d == nil)
+ if (d == nil) {
[self warnWithFormat:@"Could not parse dateString: '%@'",
dateString];
- [self setDay:[NSNumber numberWithInt:[d dayOfMonth]]];
+ }
+ [self setDay: [NSNumber numberWithInt:[d dayOfMonth]]];
[self setMonth:[NSNumber numberWithInt:[d monthOfYear]]];
- [self setYear:[NSNumber numberWithInt:[d yearOfCommonEra]]];
+ [self setYear: [NSNumber numberWithInt:[d yearOfCommonEra]]];
[super takeValuesFromRequest:_rq inContext:_ctx];
}