-
Notifications
You must be signed in to change notification settings - Fork 10
/
Norway.php
executable file
·179 lines (159 loc) · 4.76 KB
/
Norway.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
/**
* Driver class that calculates Norwegian holidays
*
* PHP Version 5
*
* Copyright (c) 1997-2008 The PHP Group
*
* This source file is subject to version 3.0 of the PHP license,
* that is bundled with this package in the file LICENSE, and is
* available at through the world-wide-web at
* http://www.php.net/license/3_01.txt.
* If you did not receive a copy of the PHP license and are unable to
* obtain it through the world-wide-web, please send a note to
* license@php.net so we can mail you a copy immediately.
*
* @category Date
* @package Date_Holidays
* @author Vegard Fiksdal <fiksdal@sensorlink.no>
* @license http://www.php.net/license/3_01.txt PHP License 3.0.1
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
require_once 'Christian.php';
/**
* Driver class that calculates Norwegian holidays
*
* @category Date
* @package Date_Holidays
* @subpackage Driver
* @author Vegard Fiksdal <fiksdal@sensorlink.no>
* @license http://www.php.net/license/3_01.txt PHP License 3.0.1
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
* Sensorlink AS (c) 2006
*/
class Date_Holidays_Driver_Norway extends Date_Holidays_Driver
{
/**
* this driver's name
*
* @access protected
* @var string
*/
var $_driverName = 'Norway';
/**
* Constructor
*
* Use the Date_Holidays::factory() method to construct an object of a certain
* driver
*
* @access protected
*/
protected function __construct()
{
}
/**
* Build the internal arrays that contain data about the calculated holidays
*
* @access protected
* @return boolean true on success, otherwise a PEAR_ErrorStack object
* @throws object PEAR_ErrorStack
*/
function _buildHolidays()
{
/**
* New Year's Day
*/
$this->_addHoliday('newYearsDay',
$this->_year . '-01-01',
'New Year\'s Day');
/**
* Easter Sunday
*/
$easterDate = Date_Holidays_Driver_Norway::calcEaster($this->_year);
$this->_addHoliday('easter', $easterDate, 'Easter Sunday');
/**
* Good Friday / Black Friday
*/
$goodFridayDate = $this->_addDays($easterDate, -2);
$this->_addHoliday('goodFriday', $goodFridayDate, 'Good Friday');
/**
* Easter Monday
*/
$this->_addHoliday('easterMonday',
$easterDate->getNextDay(),
'Easter Monday');
/**
* May Day
*/
$this->_addHoliday('mayDay', $this->_year . '-05-01', 'May Day');
/**
* Pentecost (determines Whit Monday, Ascension Day and Feast of
* Corpus Christi)
*/
$pentecostDate = $this->_addDays($easterDate, 49);
$this->_addHoliday('pentecost', $pentecostDate, 'Pentecost');
/**
* Ascension Day
*/
$ascensionDayDate = $this->_addDays($pentecostDate, -10);
$this->_addHoliday('ascensionDay', $ascensionDayDate, 'Ascension Day');
/**
* Norwegian National Day
*/
$this->_addHoliday('norwayNationalDay', $this->_year . '-05-17',
'Norwegian National Day');
/**
* Christmas Eve
*/
$this->_addHoliday('christmasEve', $this->_year . '-12-24', 'Christmas Eve');
/**
* Christmas day
*/
$this->_addHoliday('christmasDay', $this->_year . '-12-25', 'Christmas Day');
/**
* Boxing day
*/
$this->_addHoliday('boxingDay', $this->_year . '-12-26', 'Boxing Day');
/**
* New Year's Eve
*/
$this->_addHoliday('newYearsEve',
$this->_year . '-12-31',
'New Year\'s Eve');
if (Date_Holidays::errorsOccurred()) {
return Date_Holidays::getErrorStack();
}
return true;
}
/**
* Calculates the date for Easter. Actually this methods delegates the
* calculation to the {@link Date_Holidays_Driver_Christian#calcEaster()} method.
*
* @param int $year year
*
* @static
* @access private
* @return object Date
*/
function calcEaster($year)
{
return Date_Holidays_Driver_Christian::calcEaster($year);
}
/**
* Method that returns an array containing the ISO3166 codes that may possibly
* identify a driver.
*
* @static
* @access public
* @return array possible ISO3166 codes
*/
function getISO3166Codes()
{
return array('no', 'nor');
}
}
?>