jcal-zmanim 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +2 -0
- package/build/AppUtils.d.ts +109 -0
- package/build/AppUtils.js +394 -0
- package/build/GeneralUtils.d.ts +43 -0
- package/build/GeneralUtils.js +93 -0
- package/build/JCal/Dafyomi.d.ts +27 -0
- package/build/JCal/Dafyomi.js +131 -0
- package/build/JCal/Location.d.ts +33 -0
- package/build/JCal/Location.js +80 -0
- package/build/JCal/Molad.d.ts +39 -0
- package/build/JCal/Molad.js +95 -0
- package/build/JCal/PirkeiAvos.d.ts +13 -0
- package/build/JCal/PirkeiAvos.js +172 -0
- package/build/JCal/Sedra.d.ts +63 -0
- package/build/JCal/Sedra.js +186 -0
- package/build/JCal/Utils.d.ts +225 -0
- package/build/JCal/Utils.js +666 -0
- package/build/JCal/Zmanim.d.ts +95 -0
- package/build/JCal/Zmanim.js +224 -0
- package/build/JCal/jDate.d.ts +203 -0
- package/build/JCal/jDate.js +647 -0
- package/build/Locations.d.ts +7 -0
- package/build/Locations.js +1308 -0
- package/build/Notifications.d.ts +14 -0
- package/build/Notifications.js +1040 -0
- package/build/Settings.d.ts +25 -0
- package/build/Settings.js +75 -0
- package/build/ZmanTypes.d.ts +34 -0
- package/build/ZmanTypes.js +184 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +59 -0
- package/package.json +33 -0
- package/src/AppUtils.ts +500 -0
- package/src/GeneralUtils.ts +84 -0
- package/src/JCal/Dafyomi.ts +139 -0
- package/src/JCal/Location.ts +100 -0
- package/src/JCal/Molad.ts +105 -0
- package/src/JCal/PirkeiAvos.ts +180 -0
- package/src/JCal/Sedra.ts +215 -0
- package/src/JCal/Utils.ts +732 -0
- package/src/JCal/Zmanim.ts +270 -0
- package/src/JCal/jDate.ts +714 -0
- package/src/Locations.ts +1303 -0
- package/src/Notifications.ts +1243 -0
- package/src/Settings.ts +103 -0
- package/src/ZmanTypes.ts +184 -0
- package/src/index.ts +31 -0
- package/src/jcal-zmanim.d.ts +4 -0
- package/tsconfig.json +109 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import jDate from './jDate.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Computes the Sedra/Sedras of the week for the given day.
|
|
5
|
+
* The property "sedras" an array of sedras (either one or two) for the given Jewish Date
|
|
6
|
+
* Sample of use to get todays sedra in Israel:
|
|
7
|
+
* const sedras = new Sedra(new jDate(new Date(), true)).toString();
|
|
8
|
+
* The code was converted to javascript and tweaked by CBS.
|
|
9
|
+
* It is directly based on the C code in Danny Sadinoff's HebCal - Copyright (C) 1994.
|
|
10
|
+
* Portions of that code are Copyright (c) 2002 Michael J. Radwin. All Rights Reserved.
|
|
11
|
+
* Many of the algorithms were taken from hebrew calendar routines implemented by Nachum Dershowitz
|
|
12
|
+
* @property sedras {[{ eng: String, heb: String }]}
|
|
13
|
+
*/
|
|
14
|
+
export default class Sedra {
|
|
15
|
+
sedras: { eng: string, heb: string}[];
|
|
16
|
+
/**
|
|
17
|
+
* @param {jDate} jd
|
|
18
|
+
* @param {boolean} israel
|
|
19
|
+
*/
|
|
20
|
+
constructor(jd:jDate, israel:boolean) {
|
|
21
|
+
//If we are between the first day of Sukkos and Simchas Torah, the sedra will always be Vezos Habracha.
|
|
22
|
+
if (jd.Month === 7 && jd.Day >= 15 && jd.Day < (israel ? 23 : 24)) {
|
|
23
|
+
this.sedras = [Sedra.sedraList[53]];
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let sedraArray:{ eng: string, heb: string}[] = [],
|
|
28
|
+
sedraOrder = Sedra.getSedraOrder(jd.Year, israel),
|
|
29
|
+
absDate = jd.Abs,
|
|
30
|
+
index:number,
|
|
31
|
+
weekNum:number;
|
|
32
|
+
|
|
33
|
+
/* find the first saturday on or after today's date */
|
|
34
|
+
absDate = Sedra.getDayOnOrBefore(6, absDate + 6);
|
|
35
|
+
|
|
36
|
+
weekNum = (absDate - sedraOrder.firstSatInYear) / 7;
|
|
37
|
+
|
|
38
|
+
if (sedraOrder.sedraArray && weekNum >= sedraOrder.sedraArray.length) {
|
|
39
|
+
const indexLast = sedraOrder.sedraArray[sedraOrder.sedraArray.length - 1];
|
|
40
|
+
if (indexLast < 0) {
|
|
41
|
+
/* advance 2 parashiyot ahead after a doubled week */
|
|
42
|
+
index = (-indexLast) + 2;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
index = indexLast + 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
index = (sedraOrder.sedraArray
|
|
50
|
+
?sedraOrder.sedraArray[weekNum]
|
|
51
|
+
:-1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (index >= 0) {
|
|
55
|
+
sedraArray = [Sedra.sedraList[index]];
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const i = -index; /* undouble the sedra */
|
|
59
|
+
sedraArray = [Sedra.sedraList[i], Sedra.sedraList[i + 1]];
|
|
60
|
+
}
|
|
61
|
+
this.sedras = sedraArray;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Gets the sedra/s as a string. If there are two, they are seperated by a " - "
|
|
66
|
+
*/
|
|
67
|
+
toString() {
|
|
68
|
+
return this.sedras.map(s => s.eng).join(' - ');
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Gets the sedra/s as a string. If there are two, they are seperated by a " - "
|
|
73
|
+
*/
|
|
74
|
+
toStringHeb() {
|
|
75
|
+
return this.sedras.map(s => s.heb).join(' - ');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static lastCalculatedYear:{firstSatInYear:number,sedraArray?: number[],year: number,israel: boolean}|null = null;
|
|
79
|
+
static sedraList = [{ eng: 'Bereshis', heb: 'בראשית' }, { eng: 'Noach', heb: 'נח' }, { eng: 'Lech-Lecha', heb: 'לך לך' }, { eng: 'Vayera', heb: 'וירא' }, { eng: 'Chayei Sara', heb: 'חיי שרה' }, { eng: 'Toldos', heb: 'תולדות' }, { eng: 'Vayetzei', heb: 'ויצא' }, { eng: 'Vayishlach', heb: 'וישלח' }, { eng: 'Vayeishev', heb: 'וישב' }, { eng: 'Mikeitz', heb: 'מקץ' }, { eng: 'Vayigash', heb: 'ויגש' }, { eng: 'Vayechi', heb: 'ויחי' }, { eng: 'Shemos', heb: 'שמות' }, { eng: 'Va\'era', heb: 'וארא' }, { eng: 'Bo', heb: 'בא' }, { eng: 'Beshalach', heb: 'בשלח' }, { eng: 'Yisro', heb: 'יתרו' }, { eng: 'Mishpatim', heb: 'משפטים' }, { eng: 'Terumah', heb: 'תרומה' }, { eng: 'Tetzaveh', heb: 'תצוה' }, { eng: 'Ki Sisa', heb: 'כי תשא' }, { eng: 'Vayakhel', heb: 'ויקהל' }, { eng: 'Pekudei', heb: 'פקודי' }, { eng: 'Vayikra', heb: 'ויקרא' }, { eng: 'Tzav', heb: 'צו' }, { eng: 'Shmini', heb: 'שמיני' }, { eng: 'Tazria', heb: 'תזריע' }, { eng: 'Metzora', heb: 'מצורע' }, { eng: 'Achrei Mos', heb: 'אחרי מות' }, { eng: 'Kedoshim', heb: 'קדושים' }, { eng: 'Emor', heb: 'אמור' }, { eng: 'Behar', heb: 'בהר' }, { eng: 'Bechukosai', heb: 'בחקותי' }, { eng: 'Bamidbar', heb: 'במדבר' }, { eng: 'Nasso', heb: 'נשא' }, { eng: 'Beha\'aloscha', heb: 'בהעלתך' }, { eng: 'Sh\'lach', heb: 'שלח' }, { eng: 'Korach', heb: 'קרח' }, { eng: 'Chukas', heb: 'חקת' }, { eng: 'Balak', heb: 'בלק' }, { eng: 'Pinchas', heb: 'פינחס' }, { eng: 'Matos', heb: 'מטות' }, { eng: 'Masei', heb: 'מסעי' }, { eng: 'Devarim', heb: 'דברים' }, { eng: 'Va\'eschanan', heb: 'ואתחנן' }, { eng: 'Eikev', heb: 'עקב' }, { eng: 'Re\'eh', heb: 'ראה' }, { eng: 'Shoftim', heb: 'שופטים' }, { eng: 'Ki Seitzei', heb: 'כי תצא' }, { eng: 'Ki Savo', heb: 'כי תבא' }, { eng: 'Nitzavim', heb: 'נצבים' }, { eng: 'Vayeilech', heb: 'וילך' }, { eng: 'Ha\'Azinu', heb: 'האזינו' }, { eng: 'Vezos Habracha', heb: 'וזאת הברכה' }];
|
|
80
|
+
static shabbos_short = [52, 52, 53, 53, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -21, 23, 24, 25, 25, -26, -28, 30, -31, 33, 34, 35, 36, 37, 38, 39, 40, -41, 43, 44, 45, 46, 47, 48, 49, 50];
|
|
81
|
+
static shabbos_long = [52, 52, 53, 53, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -21, 23, 24, 25, 25, -26, -28, 30, -31, 33, 34, 35, 36, 37, 38, 39, 40, -41, 43, 44, 45, 46, 47, 48, 49, -50];
|
|
82
|
+
static mon_short = [51, 52, 53, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -21, 23, 24, 25, 25, -26, -28, 30, -31, 33, 34, 35, 36, 37, 38, 39, 40, -41, 43, 44, 45, 46, 47, 48, 49, -50];
|
|
83
|
+
static mon_long = [51, 52, 53, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -21, 23, 24, 25, 25, -26, -28, 30, -31, 33, 34, 34, 35, 36, 37, -38, 40, -41, 43, 44, 45, 46, 47, 48, 49, -50];
|
|
84
|
+
static thu_normal = [52, 53, 53, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -21, 23, 24, 25, 25, 25, -26, -28, 30, -31, 33, 34, 35, 36, 37, 38, 39, 40, -41, 43, 44, 45, 46, 47, 48, 49, 50];
|
|
85
|
+
static thu_normal_Israel = [52, 53, 53, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -21, 23, 24, 25, 25, -26, -28, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -41, 43, 44, 45, 46, 47, 48, 49, 50];
|
|
86
|
+
static thu_long = [52, 53, 53, 0, 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, 25, -26, -28, 30, -31, 33, 34, 35, 36, 37, 38, 39, 40, -41, 43, 44, 45, 46, 47, 48, 49, 50];
|
|
87
|
+
static shabbos_short_leap = [52, 52, 53, 53, 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -41, 43, 44, 45, 46, 47, 48, 49, -50];
|
|
88
|
+
static shabbos_long_leap = [52, 52, 53, 53, 0, 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, 28, 29, 30, 31, 32, 33, 34, 34, 35, 36, 37, -38, 40, -41, 43, 44, 45, 46, 47, 48, 49, -50];
|
|
89
|
+
static mon_short_leap = [51, 52, 53, 0, 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, 28, 29, 30, 31, 32, 33, 34, 34, 35, 36, 37, -38, 40, -41, 43, 44, 45, 46, 47, 48, 49, -50];
|
|
90
|
+
static mon_short_leap_Israel = [51, 52, 53, 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -41, 43, 44, 45, 46, 47, 48, 49, -50];
|
|
91
|
+
static mon_long_leap = [51, 52, 53, 0, 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, 28, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, -41, 43, 44, 45, 46, 47, 48, 49, 50];
|
|
92
|
+
static mon_long_leap_Israel = [51, 52, 53, 0, 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, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50];
|
|
93
|
+
static thu_short_leap = [52, 53, 53, 0, 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, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50];
|
|
94
|
+
static thu_long_leap = [52, 53, 53, 0, 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, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, -50];
|
|
95
|
+
|
|
96
|
+
static getDayOnOrBefore(day_of_week:number, date:number) {
|
|
97
|
+
return date - ((date - day_of_week) % 7);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static getSedraOrder(year:number, israel:boolean) {
|
|
101
|
+
//If the last call is within the same year as this one, we reuse the data.
|
|
102
|
+
//If memory is an issue, remove these next few lines
|
|
103
|
+
if (Sedra.lastCalculatedYear != null &&
|
|
104
|
+
Sedra.lastCalculatedYear.year === year &&
|
|
105
|
+
Sedra.lastCalculatedYear.israel === israel) {
|
|
106
|
+
return Sedra.lastCalculatedYear;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const longCheshvon = jDate.isLongCheshvan(year),
|
|
110
|
+
shortKislev = jDate.isShortKislev(year),
|
|
111
|
+
roshHashana = jDate.absJd(year, 7, 1),
|
|
112
|
+
roshHashanaDOW = Math.abs(roshHashana % 7),
|
|
113
|
+
firstSatInYear = Sedra.getDayOnOrBefore(6, roshHashana + 6);
|
|
114
|
+
let yearType,
|
|
115
|
+
sArray;
|
|
116
|
+
|
|
117
|
+
if (longCheshvon && !shortKislev)
|
|
118
|
+
yearType = 'complete';
|
|
119
|
+
else if (!longCheshvon && shortKislev)
|
|
120
|
+
yearType = 'incomplete';
|
|
121
|
+
else
|
|
122
|
+
yearType = 'regular';
|
|
123
|
+
|
|
124
|
+
if (!jDate.isJdLeapY(year)) {
|
|
125
|
+
switch (roshHashanaDOW) {
|
|
126
|
+
case 6:
|
|
127
|
+
if (yearType === 'incomplete') {
|
|
128
|
+
sArray = Sedra.shabbos_short;
|
|
129
|
+
}
|
|
130
|
+
else if (yearType === 'complete') {
|
|
131
|
+
sArray = Sedra.shabbos_long;
|
|
132
|
+
}
|
|
133
|
+
break;
|
|
134
|
+
|
|
135
|
+
case 1:
|
|
136
|
+
if (yearType === 'incomplete') {
|
|
137
|
+
sArray = Sedra.mon_short;
|
|
138
|
+
}
|
|
139
|
+
else if (yearType === 'complete') {
|
|
140
|
+
sArray = israel ? Sedra.mon_short : Sedra.mon_long;
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
|
|
144
|
+
case 2:
|
|
145
|
+
if (yearType === 'regular') {
|
|
146
|
+
sArray = israel ? Sedra.mon_short : Sedra.mon_long;
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
149
|
+
|
|
150
|
+
case 4:
|
|
151
|
+
if (yearType === 'regular') {
|
|
152
|
+
sArray = israel ? Sedra.thu_normal_Israel : Sedra.thu_normal;
|
|
153
|
+
}
|
|
154
|
+
else if (yearType === 'complete') {
|
|
155
|
+
sArray = Sedra.thu_long;
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
|
|
159
|
+
default:
|
|
160
|
+
throw 'improper sedra year type calculated.';
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else /* leap year */ {
|
|
164
|
+
switch (roshHashanaDOW) {
|
|
165
|
+
case 6:
|
|
166
|
+
if (yearType === 'incomplete') {
|
|
167
|
+
sArray = Sedra.shabbos_short_leap;
|
|
168
|
+
}
|
|
169
|
+
else if (yearType === 'complete') {
|
|
170
|
+
sArray = israel ? Sedra.shabbos_short_leap : Sedra.shabbos_long_leap;
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
|
|
174
|
+
case 1:
|
|
175
|
+
if (yearType === 'incomplete') {
|
|
176
|
+
sArray = israel ? Sedra.mon_short_leap_Israel : Sedra.mon_short_leap;
|
|
177
|
+
}
|
|
178
|
+
else if (yearType === 'complete') {
|
|
179
|
+
sArray = israel ? Sedra.mon_long_leap_Israel : Sedra.mon_long_leap;
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
|
|
183
|
+
case 2:
|
|
184
|
+
if (yearType === 'regular') {
|
|
185
|
+
sArray = israel ? Sedra.mon_long_leap_Israel : Sedra.mon_long_leap;
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
|
|
189
|
+
case 4:
|
|
190
|
+
if (yearType === 'incomplete') {
|
|
191
|
+
sArray = Sedra.thu_short_leap;
|
|
192
|
+
}
|
|
193
|
+
else if (yearType === 'complete') {
|
|
194
|
+
sArray = Sedra.thu_long_leap;
|
|
195
|
+
}
|
|
196
|
+
break;
|
|
197
|
+
|
|
198
|
+
default:
|
|
199
|
+
throw 'improper sedra year type calculated.';
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const retobj = {
|
|
204
|
+
firstSatInYear: firstSatInYear,
|
|
205
|
+
sedraArray: sArray,
|
|
206
|
+
year: year,
|
|
207
|
+
israel: israel
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
//Save the data in case the next call is for the same year
|
|
211
|
+
Sedra.lastCalculatedYear = retobj;
|
|
212
|
+
|
|
213
|
+
return retobj;
|
|
214
|
+
}
|
|
215
|
+
}
|