]> err.no Git - sope/blob - sope-core/NGExtensions/NGExtensions/NGCalendarDateRange.h
-containsDateRange: convenience method added
[sope] / sope-core / NGExtensions / NGExtensions / NGCalendarDateRange.h
1 /*
2   Copyright (C) 2004 Marcus Mueller
3
4   This file is part of OpenGroupware.org.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #ifndef __NGExtensions_NGCalendarDateRange_H_
24 #define __NGExtensions_NGCalendarDateRange_H_
25
26 #import <Foundation/NSObject.h>
27 #import <Foundation/NSArray.h>
28
29 @class NSString, NSCalendarDate;
30
31 @interface NGCalendarDateRange : NSObject <NSCopying>
32 {
33   NSCalendarDate *startDate;
34   NSCalendarDate *endDate;
35 }
36
37 + (id)calendarDateRangeWithStartDate:(NSCalendarDate *)_start
38   endDate:(NSCalendarDate *)_end;
39 - (id)initWithStartDate:(NSCalendarDate *)_start
40   endDate:(NSCalendarDate *)_end;
41
42 /* accessors */
43
44 - (NSCalendarDate *)startDate;
45 - (NSCalendarDate *)endDate;
46
47 /* comparison */
48
49 - (NSComparisonResult)compare:(NGCalendarDateRange *)other;
50
51 /* operations */
52
53 - (NGCalendarDateRange *)intersectionDateRange:(NGCalendarDateRange *)other;
54 - (NGCalendarDateRange *)unionDateRange:(NGCalendarDateRange *)other;
55
56 - (BOOL)doesIntersectWithDateRange:(NGCalendarDateRange *)_other;
57
58 - (BOOL)containsDate:(NSCalendarDate *)date;
59 - (BOOL)containsDateRange:(NGCalendarDateRange *)_range;
60
61 @end
62
63 @interface NSArray(NGCalendarDateRanges)
64
65 - (NSArray *)arrayByCreatingDateRangesFromObjectsWithStartDateKey:(NSString *)s
66   andEndDateKey:(NSString *)e;
67
68 - (unsigned)indexOfFirstIntersectingDateRange:(NGCalendarDateRange *)_range;
69 - (BOOL)dateRangeArrayContainsDate:(NSCalendarDate *)_date;
70
71 - (NSArray *)arrayByCompactingContainedDateRanges;
72
73 @end
74
75 #endif  /* __NGExtensions_NGCalendarDateRange_H_ */