-
Notifications
You must be signed in to change notification settings - Fork 5
/
Holidays.php
274 lines (246 loc) · 6.35 KB
/
Holidays.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<?php
namespace Zman\Moadim;
trait Holidays
{
/**
* Gets the first day of Pesach for a given Jewish year.
*
* @param string|int $year
* @return \Zman\Zman
*/
public static function firstDayOfPesach($year)
{
return toSecular(8, 15, $year);
}
/**
* Gets the day of Pesach Sheni for a given Jewish year.
*
* @param string|int $year
* @return \Zman\Zman
*/
public static function dayOfPesachSheni($year)
{
return toSecular(9, 14, $year);
}
/**
* Gets the first day of Shavuos for a given Jewish year.
*
* @param string|int $year
* @return \Zman\Zman
*/
public static function firstDayOfShavuos($year)
{
return toSecular(10, 6, $year);
}
/**
* Gets the first day of Rosh Hashana for a given Jewish year.
*
* @param string|int $year
* @return \Zman\Zman
*/
public static function firstDayOfRoshHashana($year)
{
return toSecular(1, 1, $year);
}
/**
* Gets the first day of Sukkos for a given Jewish year.
*
* @param string|int $year
* @return \Zman\Zman
*/
public static function firstDayOfSukkos($year)
{
return toSecular(1, 15, $year);
}
/**
* Gets the day of Shmini Atzeres for a given Jewish year.
*
* @param string|int $year
* @return \Zman\Zman
*/
public static function dayOfShminiAtzeres($year)
{
return toSecular(1, 22, $year);
}
/**
* Gets the day of Simchas Torah for a given Jewish year.
*
* @param string|int $year
* @return \Zman\Zman
*/
public static function dayOfSimchasTorah($year, $galus = true)
{
return toSecular(1, $galus ? 23 : 22, $year);
}
/**
* Gets the first day of Chanuka for a given Jewish year.
*
* @param string|int $year
* @return \Zman\Zman
*/
public static function firstDayOfChanuka($year)
{
return toSecular(3, 25, $year);
}
/**
* Gets the day of Tu Bishvat for a given Jewish year.
*
* @param string|int $year
* @return \Zman\Zman
*/
public static function dayOfTuBishvat($year)
{
return toSecular(5, 15, $year);
}
/**
* Gets the day of Purim for a given Jewish year.
*
* @param string|int $year
* @return \Zman\Zman
*/
public static function dayOfPurim($year)
{
return toSecular(7, 14, $year);
}
/**
* Gets the day of Shushan Purim for a given Jewish year.
*
* @param string|int $year
* @return \Zman\Zman
*/
public static function dayOfShushanPurim($year)
{
return toSecular(7, 15, $year)->isSaturday() ? toSecular(7, 16, $year) : toSecular(7, 15, $year);
}
/**
* Gets the day of Purim Kattan for a given Jewish year.
*
* @param string|int $year
* @return \Zman\Zman
*/
public static function dayOfPurimKattan($year)
{
return toSecular(6, 14, $year);
}
/**
* Pesach is from the 15th to the 22nd of Nisan in
* Galus, and from the 15th to the 21st in E"Y.
*
* @param bool $galus
* @return bool
*/
public function isPesach($galus = null)
{
$galus = $this->getGalusMode($galus);
return $this->gte(static::firstDayOfPesach($this->jewishYear))
&& $this->lte(static::firstDayOfPesach($this->jewishYear)->addDays($galus ? 7 : 6)->endOfDay());
}
/**
* Pesach Sheni is the 14th of Iyar.
*
* @return bool
*/
public function isPesachSheni()
{
return $this->isSameDay(static::dayOfPesachSheni($this->jewishYear));
}
/**
* Shavuos is on the 6th and 7th of Sivan in
* Galus, while it's just the 6th in E"Y.
*
* @param bool $galus
* @return bool
*/
public function isShavuos($galus = null)
{
$galus = $this->getGalusMode($galus);
return $this->jewishMonth === 10 && ($this->jewishDay === 6 || ($galus && $this->jewishDay === 7));
}
/**
* Sukkos is from the 15th to the 21st of Tishrei.
*
* @return bool
*/
public function isSukkos()
{
return $this->jewishMonth === 1 && $this->jewishDay >= 15 && $this->jewishDay <= 21;
}
/**
* Rosh Hashana is the first two days of Tishrei.
*
* @return bool
*/
public function isRoshHashana()
{
return $this->jewishMonth === 1 && ($this->jewishDay === 1 || $this->jewishDay === 2);
}
/**
* Shmini Atzeres is the 22nd day of Tishrei.
*
* @return bool
*/
public function isShminiAtzeres()
{
return $this->jewishMonth === 1 && $this->jewishDay === 22;
}
/**
* Simchas Torah is the 23rd day of Tishrei in
* Galus, and the 22nd in E"Y. Ashrei Ha'am
* SheHaShem Eloikov!!!!!!!!!!!!!!!!!!!!
*
* @return bool
*/
public function isSimchasTorah($galus = null)
{
$galus = $this->getGalusMode($galus);
return $this->jewishMonth === 1 && ($galus ? $this->jewishDay === 23 : $this->jewishDay === 22);
}
/**
* Chanuka is 8 days from the 25th of Kislev.
*
* @return bool
*/
public function isChanuka()
{
return $this->gte(static::firstDayOfChanuka($this->jewishYear))
&& $this->lte(static::firstDayOfChanuka($this->jewishYear)->addDays(7)->endOfDay());
}
/**
* Tu Bishvat is the 15th of Shvat.
*
* @return bool
*/
public function isTuBishvat()
{
return $this->isSameDay(static::dayOfTuBishvat($this->jewishYear));
}
/**
* Purim is the 14th of Adar, or the 14th of
* Adar Sheini when the year is meuberes.
*
* @return bool
*/
public function isPurim()
{
return $this->isSameDay(static::dayOfPurim($this->jewishYear));
}
/**
* Shushan Purim is usually 15th of Adar, but it
* gets pushed to the 16th if it was Shabbos.
*
* @return bool
*/
public function isShushanPurim()
{
return $this->isSameDay(static::dayOfShushanPurim($this->jewishYear));
}
/**
* Purim Kattan is the 14th of Adar Rishon.
*
* @return bool
*/
public function isPurimKattan()
{
return $this->isSameDay(static::dayOfPurimKattan($this->jewishYear));
}
}