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