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