+2004-08-15 Marcus Mueller <znek@mulle-kybernetik.com>
+
+ * v0.9.54
+
+ * UIxTimeDateControl.*, UIxTimeSelector.*, UIxDatePicker.*:
+ fixed. DatePicker expects day, month, year bindings now,
+ TimeSelector expects hour, minute, second.
+
2004-08-16 Helge Hess <helge.hess@skyrix.com>
* v0.9.53
req = [[self context] request];
NSLog(@"%@", [req formValues]);
+ [self logWithFormat:@"aptStartDate:%@ aptEndDate:%@",
+ [self aptStartDate],
+ [self aptEndDate]];
return self;
}
@interface UIxDatePicker : WOComponent
{
NSString *dateID;
- NSCalendarDate *date;
+ id day;
+ id month;
+ id year;
NSString *label;
}
- (void)dealloc {
[self->dateID release];
- [self->date release];
+ [self->day release];
+ [self->month release];
+ [self->year release];
[self->label release];
[super dealloc];
}
return self->dateID;
}
-- (void)setDate:(NSCalendarDate *)_date {
- ASSIGN(self->date, _date);
+- (void)setDay:(id)_day {
+ ASSIGN(self->day, _day);
}
-- (NSCalendarDate *)date {
- if (self->date == nil) /* HACK, return 'now' */
- return [NSCalendarDate date];
- return self->date;
+- (id)day {
+ return self->day;
+}
+- (void)setMonth:(id)_month {
+ ASSIGN(self->month, _month);
+}
+- (id)month {
+ return self->month;
+}
+- (void)setYear:(id)_year {
+ ASSIGN(self->year, _year);
+}
+- (id)year {
+ return self->year;
}
+
- (void)setLabel:(NSString *)_label {
ASSIGNCOPY(self->label, _label);
}
}
- (NSString *)formattedDateString {
- return [[self date] descriptionWithCalendarFormat:@"%Y-%m-%d"];
+ return [NSString stringWithFormat:@"%d-%02d-%02d",
+ [[self year] intValue],
+ [[self month] intValue],
+ [[self day] intValue]];
}
- (NSString *)dateFormat {
[self debugWithFormat:@"got no date string!"];
return;
}
-
+
d = [NSCalendarDate dateWithString:dateString calendarFormat:@"%Y-%m-%d"];
if (d == nil)
[self logWithFormat:@"WARNING: Could not parse dateString: '%@'",
dateString];
[self logWithFormat:@"%s setting date: %@", __PRETTY_FUNCTION__, d];
- [self setDate:d];
+ [self setDay:[NSNumber numberWithInt:[d dayOfMonth]]];
+ [self setMonth:[NSNumber numberWithInt:[d monthOfYear]]];
+ [self setYear:[NSNumber numberWithInt:[d yearOfCommonEra]]];
+
+ [super takeValuesFromRequest:_rq inContext:_ctx];
}
@end /* UIxDatePicker */
@interface UIxTimeDateControl : WOComponent
{
- NSString *controlID;
+ NSString *controlID;
+ NSString *label;
NSCalendarDate *date;
- NSString *label;
-
- NSCalendarDate *timeComponent;
- NSCalendarDate *dateComponent;
+ id hour;
+ id minute;
+ id second;
+ id day;
+ id month;
+ id year;
}
+- (void)setControlID:(NSString *)_controlID;
+- (NSString *)controlID;
+- (void)setLabel:(NSString *)_label;
+- (NSString *)label;
+- (void)setDate:(NSCalendarDate *)_date;
+- (NSCalendarDate *)date;
+
+- (void)setHour:(id)_hour;
+- (id)hour;
+- (void)setMinute:(id)_minute;
+- (id)minute;
+- (void)setSecond:(id)_second;
+- (id)second;
+- (void)setDay:(id)_day;
+- (id)day;
+- (void)setMonth:(id)_month;
+- (id)month;
+- (void)setYear:(id)_year;
+- (id)year;
+
- (NSString *)timeID;
- (NSString *)dateID;
-- (void)setTimeComponent:(NSCalendarDate *)_timeComponent;
-- (void)setDateComponent:(NSCalendarDate *)_dateComponent;
-
+- (void)_setDate:(NSCalendarDate *)_date;
+
@end
#include "common.h"
@implementation UIxTimeDateControl
- (void)dealloc {
- [self->controlID release];
- [self->date release];
- [self->label release];
- [self->timeComponent release];
- [self->dateComponent release];
+ [self->controlID release];
+ [self->label release];
+ [self->date release];
+ [self->hour release];
+ [self->minute release];
+ [self->second release];
+ [self->day release];
+ [self->month release];
+ [self->year release];
[super dealloc];
}
- (NSString *)controlID {
return self->controlID;
}
-- (void)setDate:(NSCalendarDate *)_date {
- ASSIGN(self->date, _date);
- [self setTimeComponent:_date];
- [self setDateComponent:_date];
-}
-- (NSCalendarDate *)date {
- return self->date;
-}
- (void)setLabel:(NSString *)_label {
ASSIGNCOPY(self->label, _label);
}
- (NSString *)label {
return self->label;
}
+- (void)setDate:(NSCalendarDate *)_date {
+ [self _setDate:_date];
+ [self setHour:[NSNumber numberWithInt:[_date hourOfDay]]];
+ [self setMinute:[NSNumber numberWithInt:[_date minuteOfHour]]];
+ [self setYear:[NSNumber numberWithInt:[_date yearOfCommonEra]]];
+ [self setMonth:[NSNumber numberWithInt:[_date monthOfYear]]];
+ [self setDay:[NSNumber numberWithInt:[_date dayOfMonth]]];
+}
+- (void)_setDate:(NSCalendarDate *)_date {
+ ASSIGN(self->date, _date);
+}
+- (NSCalendarDate *)date {
+ return self->date;
+}
-- (void)setTimeComponent:(NSCalendarDate *)_timeComponent {
- ASSIGN(self->timeComponent, _timeComponent);
+- (void)setHour:(id)_hour {
+ ASSIGN(self->hour, _hour);
+}
+- (id)hour {
+ return self->hour;
+}
+- (void)setMinute:(id)_minute {
+ ASSIGN(self->minute, _minute);
}
-- (NSCalendarDate *)timeComponent {
- return self->timeComponent;
+- (id)minute {
+ return self->minute;
+}
+- (void)setSecond:(id)_second {
+ ASSIGN(self->second, _second);
+}
+- (id)second {
+ return self->second;
}
-- (void)setDateComponent:(NSCalendarDate *)_dateComponent {
- ASSIGN(self->dateComponent, _dateComponent);
+- (void)setDay:(id)_day {
+ ASSIGN(self->day, _day);
+}
+- (id)day {
+ return self->day;
}
-- (NSCalendarDate *)dateComponent {
- return self->dateComponent;
+- (void)setMonth:(id)_month {
+ ASSIGN(self->month, _month);
+}
+- (id)month {
+ return self->month;
+}
+- (void)setYear:(id)_year {
+ ASSIGN(self->year, _year);
+}
+- (id)year {
+ return self->year;
}
- (NSString *)timeID {
- (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
NSCalendarDate *d;
-
+ unsigned _year, _month, _day, _hour, _minute, _second;
+
/* call super, so that the form values are applied on the popups */
[super takeValuesFromRequest:_rq inContext:_ctx];
-
- d = [self dateComponent];
- [self logWithFormat:@"base date: %@", d];
-
- d = [d hour:[[self timeComponent] hourOfDay]
- minute:[[self timeComponent] minuteOfHour]];
- [self logWithFormat:@"%s newDate:%@",
- __PRETTY_FUNCTION__,
- d];
-
- if (d == nil)
- return;
- [self setDate:d];
+
+ _year = [[self year] intValue];
+ if(_year == 0)
+ return;
+
+ _month = [[self month] intValue];
+ _day = [[self day] intValue];
+ _hour = [[self hour] intValue];
+ _minute = [[self minute] intValue];
+ _second = [[self second] intValue];
+ d = [NSCalendarDate dateWithYear:_year
+ month:_month
+ day:_day
+ hour:_hour
+ minute:_minute
+ second:_second
+ timeZone:[[self date] timeZone]];
+ [self debugWithFormat:@"%s setting date:%@", __PRETTY_FUNCTION__, d];
+ [self _setDate:d];
}
@end /* UIxTimeDateControl */
xmlns:const="http://www.skyrix.com/od/constant"
xmlns:rsrc="OGo:url"
>
- <var:component className="UIxTimeSelector" timeID="timeID"
- date="timeComponent" />
- <var:component className="UIxDatePicker" dateID="dateID"
- date="dateComponent"
- label="label" />
+ <table cellpadding="0" cellspacing="2">
+ <tr>
+ <td>
+ <var:component className="UIxTimeSelector"
+ timeID="timeID"
+ hour="hour"
+ minute="minute"
+ />
+ </td>
+ <td>
+ <var:component className="UIxDatePicker"
+ dateID="dateID"
+ year="year"
+ month="month"
+ day="day"
+ label="label"
+ />
+ </td>
+ </tr>
+ </table>
</span>
@interface UIxTimeSelector : WOComponent
{
- NSString *timeID;
- NSCalendarDate *date;
- BOOL combined;
- NSString *minuteInterval;
- id item;
- NSArray *hours, *minutes;
-}
-
-- (NSArray *)hours;
-- (NSArray *)minutes;
+ NSString *timeID;
+ id hour;
+ id minute;
+ NSString *minuteInterval;
+}
+
+- (void)setTimeID:(NSString *)_timeID;
+- (NSString *)timeID;
+- (void)setHour:(id)_hour;
+- (id)hour;
+- (void)setMinute:(id)_minute;
+- (id)minute;
+- (void)setMinuteInterval:(NSString *)_minuteInterval;
- (NSString *)minuteInterval;
@end
- (void)dealloc {
[self->timeID release];
- [self->date release];
+ [self->hour release];
+ [self->minute release];
[self->minuteInterval release];
- [self->item release];
- [self->hours release];
- [self->minutes release];
[super dealloc];
}
return self->timeID;
}
-- (void)setDate:(NSCalendarDate *)_date {
- ASSIGN(self->date, _date);
+- (void)setHour:(id)_hour {
+ ASSIGN(self->hour, _hour);
+}
+- (id)hour {
+ return self->hour;
}
-- (NSCalendarDate *)date {
- if (self->date == nil) /* HACK, return 'now' */
- return [NSCalendarDate date];
- return self->date;
+- (void)setMinute:(id)_minute {
+ ASSIGN(self->minute, _minute);
+}
+- (id)minute {
+ return self->minute;
}
- (void)setMinuteInterval:(NSString *)_minuteInterval {
return self->minuteInterval;
}
-- (void)setItem:(id)_item {
- ASSIGN(self->item, _item);
-}
-- (id)item {
- return self->item;
-}
-
-- (NSString *)hoursName {
- return [[self timeID] stringByAppendingString:@"_hours"];
-}
-
-- (NSString *)minutesName {
- return [[self timeID] stringByAppendingString:@"_minutes"];
-}
-
-- (NSArray *)hours {
- NSMutableArray *values;
- unsigned i, count;
-
- if (self->hours)
- return self->hours;
-
- count = 24;
- values = [NSMutableArray arrayWithCapacity:count];
- for (i = 0; i < count; i++)
- [values addObject:[NSNumber numberWithInt:i]];
-
- self->hours = [values copy];
- return self->hours;
-}
-
-- (NSArray *)minutes {
- NSMutableArray *values;
- unsigned i, count, iv;
-
- if (self->minutes)
- return self->minutes;
-
- iv = [[self minuteInterval] intValue];
-
- count = 60;
- values = [NSMutableArray arrayWithCapacity:count];
- for (i = 0; i < count; i += iv)
- [values addObject:[NSNumber numberWithInt:i]];
-
- self->minutes = [values copy];
- return self->minutes;
-}
-
-- (NSNumber *)selectedHour {
- return [[self hours] objectAtIndex:[[self date] hourOfDay]];
-}
-
-- (NSNumber *)selectedMinute {
- return [[self minutes] objectAtIndex:[[self date] minuteOfHour]];
-}
-
-- (NSString *)displayString {
- char buf[8];
- sprintf(buf, "%02d", [item intValue]);
- return [NSString stringWithCString:buf];
-}
-
-/* action */
-
-- (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
- NSString *h, *m;
- NSCalendarDate *d;
-
- h = [_rq formValueForKey:[self hoursName]];
- m = [_rq formValueForKey:[self minutesName]];
-
- [self logWithFormat:@"got hour (%@): %@", [self hoursName], h];
- [self logWithFormat:@"got minute (%@): %@", [self minutesName], m];
-
- if (h == nil)
- return;
-
- d = [[self date] hour:[h intValue] minute:[m intValue]];
- [self logWithFormat:@"%s setting date:%@", __PRETTY_FUNCTION__, d];
- [self setDate:d];
+- (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
+ /* call super, so that the form values are applied on the popups */
+ [super takeValuesFromRequest:_rq inContext:_ctx];
}
@end /* UIxTimeSelector */
xmlns:rsrc="OGo:url"
var:id="timeID"
>
- <var:popup name="hoursName"
- list="hours"
- item="item"
- displayString="displayString"
- selection="selectedHour"
- />:<var:popup name="minutesName"
- list="minutes"
- item="item"
- displayString="displayString"
- selection="selectedMinute"
- />
+ <var:time-field hour="hour"
+ minute="minute"
+ minuteInterval="minuteInterval"
+ name="timeID"
+ />
</span>
# $Id$
-SUBMINOR_VERSION:=53
+SUBMINOR_VERSION:=54
# v0.9.41 requires libNGObjWeb v4.2.431
# v0.9.31 requires libWEExtensions v4.2.52