]> err.no Git - sope/blob - sope-core/NGExtensions/NGExtensions/NSCalendarDate+misc.h
14e6b763d2b22dea1612ee2b252437a1dfd59b40
[sope] / sope-core / NGExtensions / NGExtensions / NSCalendarDate+misc.h
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
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_NSCalendarDate_misc_H__
23 #define __NGExtensions_NSCalendarDate_misc_H__
24
25 #import <Foundation/NSDate.h>
26 #import <Foundation/NSString.h>
27
28 #if NeXT_Foundation_LIBRARY || GNUSTEP_BASE_LIBRARY
29 #  import <Foundation/NSCalendarDate.h>
30 #endif
31
32 @class NSArray, NSTimeZone;
33
34 @interface NSCalendarDate(misc)
35
36 - (int)weekOfMonth;
37 - (int)weekOfYear;
38 - (short)numberOfWeeksInYear;
39 + (NSArray *)mondaysOfYear:(int)_year timeZone:(NSTimeZone *)_tz;
40 - (NSArray *)mondaysOfYear;
41 - (NSCalendarDate *)firstMondayAndLastWeekInYear:(short *)_lastWeek;
42 + (NSCalendarDate *)mondayOfWeek:(int)_weekNumber inYear:(int)_year
43   timeZone:(NSTimeZone *)_tz;
44 - (NSCalendarDate *)mondayOfWeek:(int)_weekNumber;
45
46 + (NSCalendarDate *)dateForJulianNumber:(long)_jn;
47 - (long)julianNumber;
48
49 - (NSCalendarDate *)firstDayOfMonth;
50 - (NSCalendarDate *)lastDayOfMonth;
51 - (NSCalendarDate *)mondayOfWeek;
52 - (NSCalendarDate *)beginOfDay;
53 - (NSCalendarDate *)endOfDay;
54 - (int)numberOfDaysInMonth;
55
56 - (BOOL)isDateOnSameDay:(NSCalendarDate *)_date;
57 - (BOOL)isDateInSameWeek:(NSCalendarDate *)_date;
58 - (BOOL)isInLeapYear;
59
60 - (BOOL)isToday;
61 - (NSCalendarDate *)yesterday;
62 - (NSCalendarDate *)tomorrow;
63 - (BOOL)isForenoon;
64 - (BOOL)isAfternoon;
65
66 - (NSCalendarDate *)nextYear;
67 - (NSCalendarDate *)lastYear;
68
69 /* returns a date on the same day with the specified time */
70 - (NSCalendarDate *)hour:(int)_hour minute:(int)_minute second:(int)_second;
71 - (NSCalendarDate *)hour:(int)_hour minute:(int)_minute;
72
73 /*
74   applies the following modifications:
75     if year >= 70 && year < 135
76       year = 1900 + year
77     elif year >= 0 && year < 70
78       year = 2000 + year
79 */
80
81 - (NSCalendarDate *)y2kDate;
82
83 /*
84   adding years, months and days while *keeping* the clock time, eg:
85
86     d1 = [NSCalendarDate dateWithYear:2000 month:2 day:15
87                          hour:12 minute:0 second:0
88                          timeZone:@"MET"];
89     d2 = [d1 dateByAddingYear:0 month:3 day:0];
90
91     [d2 hourOfDay] will be '15' though the timezone changed from
92     MET to MET-DST.
93
94     -dateByAddingYears:months:days:hours:minutes:seconds: which can
95     be found in NSCalendarDate will not keep the clock time (the time
96     will be adjusted in the new DST timezone
97 */
98
99 - (NSCalendarDate *)dateByAddingYears:(int)_years
100   months:(int)_months
101   days:(int)_days;
102
103 /* calculate easter ... */
104
105 - (NSCalendarDate *)easterOfYear;
106
107 @end
108
109
110 @interface NSCalendarDate(CalMatrix)
111
112 - (NSArray *)calendarMatrixWithStartDayOfWeek:(short)_caldow
113   onlyCurrentMonth:(BOOL)_onlyThisMonth;
114
115 @end
116
117
118 @interface NSString(FuzzyDayOfWeek)
119
120 - (int)dayOfWeekInEnglishOrGerman;
121
122 @end
123
124
125 #endif /* __NGExtensions_NSCalendarDate_misc_H__ */