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 "iCalDateTime.h"
27 #import "NSCalendarDate+NGCards.h"
29 #import "iCalFreeBusy.h"
31 @implementation iCalFreeBusy
33 - (Class) classForTag: (NSString *) classTag
37 if ([classTag isEqualToString: @"DTEND"])
38 tagClass = [iCalDateTime class];
39 else if ([classTag isEqualToString: @"FREEBUSY"])
40 tagClass = [CardElement class];
42 tagClass = [super classForTag: classTag];
48 - (void) setEndDate: (NSCalendarDate *) newEndDate
50 [(iCalDateTime *) [self uniqueChildWithTag: @"dtend"]
51 setDateTime: newEndDate];
54 - (NSCalendarDate *) endDate
56 return [(iCalDateTime *) [self uniqueChildWithTag: @"dtend"]
62 return ([[self childrenWithTag: @"dtend"] count] > 0);
65 - (NSString *) _freeBusyTypeString: (iCalFreeBusyType) type
77 case iCalFBBusyUnavailable:
78 typeString = @"BUSY-UNAVAILABLE";
81 typeString = @"BUSY-TENTATIVE";
87 - (void) addFreeBusyFrom: (NSCalendarDate *) start
88 to: (NSCalendarDate *) end
89 type: (iCalFreeBusyType) type
91 CardElement *freeBusyElement;
93 NSCalendarDate *utcStart, *utcEnd;
96 uTZ = [NSTimeZone timeZoneWithAbbreviation: @"GMT"];
97 utcStart = [start copy];
99 [utcStart setTimeZone: uTZ];
100 [utcEnd setTimeZone: uTZ];
102 value = [NSString stringWithFormat: @"%@Z/%@Z",
103 [utcStart iCalFormattedDateTimeString],
104 [utcEnd iCalFormattedDateTimeString]];
105 freeBusyElement = [CardElement simpleElementWithTag: @"freebusy"
107 [freeBusyElement addAttribute: @"fbtype"
108 value: [self _freeBusyTypeString: type]];
109 [self addChild: freeBusyElement];
117 - (NSString *) entityName
122 @end /* iCalFreeBusy */