2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OGo
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #include <NGObjWeb/NGObjWeb.h>
27 @interface UIxCalDateLabel : WOComponent
30 NSCalendarDate *startDate;
31 NSCalendarDate *endDate;
34 - (NSString *)dayLabel;
35 - (NSString *)weekLabel;
36 - (NSString *)monthLabel;
37 - (NSString *)yearLabel;
42 @implementation UIxCalDateLabel
45 [self->selection release];
46 [self->startDate release];
47 [self->endDate release];
51 - (void)setSelection:(NSString *)_selection {
52 ASSIGN(self->selection, _selection);
55 - (NSString *)selection {
56 return self->selection;
59 - (void)setStartDate:(NSCalendarDate *)_date {
60 ASSIGN(self->startDate, _date);
63 - (NSCalendarDate *)startDate {
64 return self->startDate;
67 - (void)setEndDate:(NSCalendarDate *)_date {
68 ASSIGN(self->endDate, _date);
71 - (NSCalendarDate *)endDate {
76 NSString *key = [self selection];
77 if([key isEqualToString:@"day"])
78 return [self dayLabel];
79 else if([key isEqualToString:@"week"])
80 return [self weekLabel];
81 else if([key isEqualToString:@"month"])
82 return [self monthLabel];
83 return [self yearLabel];
86 - (NSString *)dayLabel {
87 return [self->startDate descriptionWithCalendarFormat:@"%Y-%m-%d"];
90 - (NSString *)weekLabel {
93 label = [self->startDate descriptionWithCalendarFormat:@"%B %Y"];
94 if([self->startDate monthOfYear] != [self->endDate monthOfYear]) {
97 ext = [self->endDate descriptionWithCalendarFormat:@"%B %Y"];
98 label = [NSString stringWithFormat:@"<nobr>%@ / %@</nobr>",
105 - (NSString *)monthLabel {
106 return [self->startDate descriptionWithCalendarFormat:@"%B %Y"];
109 - (NSString *)yearLabel {
110 return [self->startDate descriptionWithCalendarFormat:@"%Y"];