2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE 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 SOPE 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 SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #import <Foundation/NSArray.h>
23 #import <Foundation/NSString.h>
24 #import <Foundation/NSTimeZone.h>
26 #import "CardGroup+iCal.h"
27 #import "iCalDateTime.h"
28 #import "NSCalendarDate+NGCards.h"
30 #import "iCalFreeBusy.h"
32 @implementation iCalFreeBusy
34 - (Class) classForTag: (NSString *) classTag
38 if ([classTag isEqualToString: @"DTEND"])
39 tagClass = [iCalDateTime class];
40 else if ([classTag isEqualToString: @"FREEBUSY"])
41 tagClass = [CardElement class];
43 tagClass = [super classForTag: classTag];
49 - (void) setEndDate: (NSCalendarDate *)_date
51 [self setDate: _date forDateTimeValue: @"dtend"];
54 - (NSCalendarDate *) endDate
56 return [self dateForDateTimeValue: @"dtend"];
61 return ([[self childrenWithTag: @"dtend"] count] > 0);
64 - (NSString *) _freeBusyTypeString: (iCalFreeBusyType) type
76 case iCalFBBusyUnavailable:
77 typeString = @"BUSY-UNAVAILABLE";
80 typeString = @"BUSY-TENTATIVE";
86 - (void) addFreeBusyFrom: (NSCalendarDate *) start
87 to: (NSCalendarDate *) end
88 type: (iCalFreeBusyType) type
90 CardElement *freeBusyElement;
92 NSCalendarDate *utcStart, *utcEnd;
95 uTZ = [NSTimeZone timeZoneWithAbbreviation: @"GMT"];
96 utcStart = [start copy];
98 [utcStart setTimeZone: uTZ];
99 [utcEnd setTimeZone: uTZ];
101 value = [NSString stringWithFormat: @"%@Z/%@Z",
102 [utcStart iCalFormattedDateTimeString],
103 [utcEnd iCalFormattedDateTimeString]];
104 freeBusyElement = [CardElement simpleElementWithTag: @"freebusy"
106 [freeBusyElement addAttribute: @"fbtype"
107 value: [self _freeBusyTypeString: type]];
108 [self addChild: freeBusyElement];
116 - (NSString *) entityName
121 @end /* iCalFreeBusy */