1 /* UIxCalWeekView.m - this file is part of SOGo
3 * Copyright (C) 2006 Inverse groupe conseil
5 * Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
7 * This file is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This file is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #import <Foundation/NSArray.h>
24 #import <Foundation/NSCalendarDate.h>
25 #import <Foundation/NSKeyValueCoding.h>
26 #import <Foundation/NSString.h>
28 #import <EOControl/EOQualifier.h>
30 #import <NGExtensions/NSCalendarDate+misc.h>
32 #include "UIxCalWeekView.h"
34 @implementation UIxCalWeekView
36 - (NSCalendarDate *) startDate
38 return [[[super startDate] mondayOfWeek] beginOfDay];
41 - (NSCalendarDate *) endDate
45 if([self shouldDisplayWeekend])
50 return [[[self startDate] dateByAddingYears:0 months:0 days:offset
51 hours:0 minutes:0 seconds:0]
55 // - (NSArray *) appointments
57 // return [self fetchCoreAppointmentsInfos];
62 - (NSDictionary *) weekBeforePrevWeekQueryParameters
64 return [self _dateQueryParametersWithOffset: -14];
67 - (NSDictionary *) prevWeekQueryParameters
69 return [self _dateQueryParametersWithOffset: -7];
72 - (NSDictionary *) nextWeekQueryParameters
74 return [self _dateQueryParametersWithOffset: 7];
77 - (NSDictionary *) weekAfterNextWeekQueryParameters
79 return [self _dateQueryParametersWithOffset: 14];
82 - (NSString *) _weekNumberWithOffsetFromToday: (int) offset
87 date = [[self startDate] dateByAddingYears: 0 months: 0 days: (offset * 7)
88 hours:0 minutes: 0 seconds: 0];
89 format = [self labelForKey: @"Week %d"];
91 return [NSString stringWithFormat: format, [date weekOfYear]];
94 - (NSString *) weekBeforeLastWeekName
96 return [self _weekNumberWithOffsetFromToday: -2];
99 - (NSString *) lastWeekName
101 return [self _weekNumberWithOffsetFromToday: -1];
104 - (NSString *) currentWeekName
106 return [self _weekNumberWithOffsetFromToday: 0];
109 - (NSString *) nextWeekName
111 return [self _weekNumberWithOffsetFromToday: 1];
114 - (NSString *) weekAfterNextWeekName
116 return [self _weekNumberWithOffsetFromToday: 2];
119 @end /* UIxCalWeekView */