hebrew-date 1.0.7 → 1.0.8
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 +1 -1
- package/README.md +13 -137
- package/lib/index.js +96 -80
- package/package.json +1 -2
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2016-
|
|
3
|
+
Copyright (c) 2016-26 Ionică Bizău <bizauionica@gmail.com> (https://ionicabizau.net)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,52 +1,13 @@
|
|
|
1
1
|
<!-- Please do not edit this file. Edit the `blah` field in the `package.json` instead. If in doubt, open an issue. -->
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
3
|
# hebrew-date
|
|
21
4
|
|
|
22
5
|
[![Support me on Patreon][badge_patreon]][patreon] [![Buy me a book][badge_amazon]][amazon] [![PayPal][badge_paypal_donate]][paypal-donations] [](https://github.com/IonicaBizau/ama) [](https://www.npmjs.com/package/hebrew-date) [](https://www.npmjs.com/package/hebrew-date) [](https://www.codementor.io/@johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github)
|
|
23
6
|
|
|
24
7
|
<a href="https://www.buymeacoffee.com/H96WwChMy" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/yellow_img.png" alt="Buy Me A Coffee"></a>
|
|
25
8
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
9
|
> Convert the date objects into the Hebrew calendar correspondant.
|
|
33
10
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
11
|
## :cloud: Installation
|
|
51
12
|
|
|
52
13
|
```sh
|
|
@@ -57,22 +18,8 @@ npm install --save hebrew-date
|
|
|
57
18
|
yarn add hebrew-date
|
|
58
19
|
```
|
|
59
20
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
21
|
## :clipboard: Example
|
|
73
22
|
|
|
74
|
-
|
|
75
|
-
|
|
76
23
|
```js
|
|
77
24
|
var hebrewDate = require("hebrew-date");
|
|
78
25
|
|
|
@@ -85,41 +32,12 @@ console.log(hebrewDate(new Date(2016, october, 3)));
|
|
|
85
32
|
// { year: 5777, month: 1, date: 1, month_name: 'Tishri' }
|
|
86
33
|
```
|
|
87
34
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
## :question: Get Help
|
|
100
|
-
|
|
101
|
-
There are few ways to get help:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long you add a link to your Stack Overflow question.
|
|
106
|
-
2. For bug reports and feature requests, open issues. :bug:
|
|
107
|
-
3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
35
|
## :memo: Documentation
|
|
116
36
|
|
|
117
|
-
|
|
118
37
|
### `hebrewDate(inputDate, inputMonth, inputDate)`
|
|
119
38
|
Convert the Gregorian dates into Hebrew calendar dates.
|
|
120
39
|
|
|
121
40
|
#### Params
|
|
122
|
-
|
|
123
41
|
- **Date|Number** `inputDate`: The date object (representing the Gregorian date) or the year.
|
|
124
42
|
- **Number** `inputMonth`: The Gregorian month (**one-indexed**, January being `1`!).
|
|
125
43
|
- **Number** `inputDate`: The Gregorian date.
|
|
@@ -131,80 +49,38 @@ Convert the Gregorian dates into Hebrew calendar dates.
|
|
|
131
49
|
- `month_name`: The Hebrew month name.
|
|
132
50
|
- `date`: The Hebrew date.
|
|
133
51
|
|
|
52
|
+
## :question: Get Help
|
|
134
53
|
|
|
54
|
+
There are a few ways to get help:
|
|
135
55
|
|
|
56
|
+
1. Please [post questions on Stack Overflow](https://stackoverflow.com/questions/ask). You can open issues with questions, as long as you add a link to your Stack Overflow question.
|
|
57
|
+
2. For bug reports and feature requests, open issues. :bug:
|
|
58
|
+
3. For direct and quick help, you can [use Codementor](https://www.codementor.io/johnnyb). :rocket:
|
|
136
59
|
|
|
60
|
+
## :yum: How to Contribute
|
|
137
61
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
## :yum: How to contribute
|
|
148
62
|
Have an idea? Found a bug? See [how to contribute][contributing].
|
|
149
63
|
|
|
64
|
+
## :sparkling_heart: Support My Projects
|
|
150
65
|
|
|
151
|
-
|
|
152
|
-
I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously,
|
|
153
|
-
this takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute (even resell it).
|
|
154
|
-
|
|
155
|
-
However, if you get some profit from this or just want to encourage me to continue creating stuff, there are few ways you can do it:
|
|
66
|
+
I open-source almost everything I can, and I try to reply to everyone needing help using these projects. Obviously, this takes time. You can integrate and use these projects in your applications *for free*! You can even change the source code and redistribute it (even resell it).
|
|
156
67
|
|
|
68
|
+
However, if you get some profit from this or just want to encourage me to continue creating stuff, there are a few ways you can do it:
|
|
157
69
|
|
|
158
70
|
- Starring and sharing the projects you like :rocket:
|
|
159
|
-
- [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you
|
|
71
|
+
- [![Buy me a book][badge_amazon]][amazon]—I love books! I will remember you for years if you buy me one. :grin: :book:
|
|
160
72
|
- [![PayPal][badge_paypal]][paypal-donations]—You can make one-time donations via PayPal. I'll probably buy a ~~coffee~~ tea. :tea:
|
|
161
73
|
- [![Support me on Patreon][badge_patreon]][patreon]—Set up a recurring monthly donation and you will get interesting news about what I'm doing (things that I don't share with everyone).
|
|
162
|
-
- **Bitcoin**—You can send me bitcoins at this address (or scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`
|
|
163
|
-
|
|
164
|
-

|
|
74
|
+
- **Bitcoin**—You can send me bitcoins at this address (or by scanning the code below): `1P9BRsmazNQcuyTxEqveUsnf5CERdq35V6`
|
|
165
75
|
|
|
76
|
+

|
|
166
77
|
|
|
167
78
|
Thanks! :heart:
|
|
168
79
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
## :dizzy: Where is this library used?
|
|
185
|
-
If you are using this library in one of your projects, add it in this list. :sparkles:
|
|
186
|
-
|
|
187
|
-
- `afui-react`
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
80
|
## :scroll: License
|
|
200
81
|
|
|
201
82
|
[MIT][license] © [Ionică Bizău][website]
|
|
202
83
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
84
|
[license]: /LICENSE
|
|
209
85
|
[website]: https://ionicabizau.net
|
|
210
86
|
[contributing]: /CONTRIBUTING.md
|
|
@@ -214,5 +90,5 @@ If you are using this library in one of your projects, add it in this list. :spa
|
|
|
214
90
|
[badge_paypal]: https://ionicabizau.github.io/badges/paypal.svg
|
|
215
91
|
[badge_paypal_donate]: https://ionicabizau.github.io/badges/paypal_donate.svg
|
|
216
92
|
[patreon]: https://www.patreon.com/ionicabizau
|
|
217
|
-
[amazon]:
|
|
93
|
+
[amazon]: https://amzn.eu/hRo9sIZ
|
|
218
94
|
[paypal-donations]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVXDDLKKLQRJW
|
package/lib/index.js
CHANGED
|
@@ -16,41 +16,42 @@
|
|
|
16
16
|
* RBI Software Systems
|
|
17
17
|
* bhastings@rbi.com
|
|
18
18
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
MON = 1
|
|
40
|
-
TUES = 2
|
|
41
|
-
WED = 3
|
|
42
|
-
THUR = 4
|
|
43
|
-
FRI = 5
|
|
44
|
-
SAT = 6
|
|
19
|
+
const GREG_SDN_OFFSET = 32045
|
|
20
|
+
, DAYS_PER_5_MONTHS = 153
|
|
21
|
+
, DAYS_PER_4_YEARS = 1461
|
|
22
|
+
, DAYS_PER_400_YEARS = 146097
|
|
23
|
+
;
|
|
24
|
+
|
|
25
|
+
const HALAKIM_PER_HOUR = 1080
|
|
26
|
+
, HALAKIM_PER_DAY = 25920
|
|
27
|
+
, HALAKIM_PER_LUNAR_CYCLE = ((29 * HALAKIM_PER_DAY) + 13753)
|
|
28
|
+
, HALAKIM_PER_METONIC_CYCLE = (HALAKIM_PER_LUNAR_CYCLE * (12 * 19 + 7))
|
|
29
|
+
;
|
|
30
|
+
|
|
31
|
+
const HEB_SDN_OFFSET = 347997
|
|
32
|
+
, NEW_MOON_OF_CREATION = 31524
|
|
33
|
+
, NOON = (18 * HALAKIM_PER_HOUR)
|
|
34
|
+
, AM3_11_20 = ((9 * HALAKIM_PER_HOUR) + 204)
|
|
35
|
+
, AM9_32_43 = ((15 * HALAKIM_PER_HOUR) + 589)
|
|
36
|
+
;
|
|
37
|
+
|
|
38
|
+
const SUN = 0
|
|
39
|
+
, MON = 1
|
|
40
|
+
, TUES = 2
|
|
41
|
+
, WED = 3
|
|
42
|
+
, THUR = 4
|
|
43
|
+
, FRI = 5
|
|
44
|
+
, SAT = 6
|
|
45
|
+
;
|
|
45
46
|
|
|
46
47
|
function weekdayarr(d0, d1, d2, d3, d4, d5, d6) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
this[0] = d0;
|
|
49
|
+
this[1] = d1;
|
|
50
|
+
this[2] = d2;
|
|
51
|
+
this[3] = d3;
|
|
52
|
+
this[4] = d4;
|
|
53
|
+
this[5] = d5;
|
|
54
|
+
this[6] = d6;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
function gregmontharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11) {
|
|
@@ -85,7 +86,8 @@ function hebrewmontharr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m
|
|
|
85
86
|
this[13] = m13;
|
|
86
87
|
}
|
|
87
88
|
|
|
88
|
-
function monthsperyeararr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9,
|
|
89
|
+
function monthsperyeararr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9,
|
|
90
|
+
m10, m11, m12, m13, m14, m15, m16, m17, m18) {
|
|
89
91
|
this[0] = m0;
|
|
90
92
|
this[1] = m1;
|
|
91
93
|
this[2] = m2;
|
|
@@ -107,10 +109,11 @@ function monthsperyeararr(m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12,
|
|
|
107
109
|
this[18] = m18;
|
|
108
110
|
}
|
|
109
111
|
|
|
110
|
-
|
|
111
|
-
gMonth = new gregmontharr("January", "February", "March", "April", "May", "June", "July", "August",
|
|
112
|
-
hMonth = new hebrewmontharr("Tishri", "Heshvan", "Kislev", "Tevet", "Shevat", "AdarI", "AdarII", "Nisan", "Iyyar", "Sivan", "Tammuz", "Av", "Elul")
|
|
113
|
-
mpy = new monthsperyeararr(12, 12, 13, 12, 12, 13, 12, 13, 12, 12, 13, 12, 12, 13, 12, 12, 13, 12, 13)
|
|
112
|
+
const gWeekday = new weekdayarr("Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur")
|
|
113
|
+
, gMonth = new gregmontharr("January", "February", "March", "April", "May", "June", "July", "August","September","October","November","December")
|
|
114
|
+
, hMonth = new hebrewmontharr("Tishri", "Heshvan", "Kislev", "Tevet", "Shevat", "AdarI", "AdarII", "Nisan", "Iyyar", "Sivan", "Tammuz", "Av", "Elul")
|
|
115
|
+
, mpy = new monthsperyeararr(12, 12, 13, 12, 12, 13, 12, 13, 12, 12, 13, 12, 12, 13, 12, 12, 13, 12, 13)
|
|
116
|
+
;
|
|
114
117
|
|
|
115
118
|
/**
|
|
116
119
|
* hebrewDate
|
|
@@ -130,19 +133,22 @@ var gWeekday = new weekdayarr("Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "S
|
|
|
130
133
|
*/
|
|
131
134
|
module.exports = function (inputDateOrYear, inputMonth, inputDate) {
|
|
132
135
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
let hebrewMonth = 0
|
|
137
|
+
, hebrewDate = 0
|
|
138
|
+
, hebrewYear = 0
|
|
139
|
+
, metonicCycle = 0
|
|
140
|
+
, metonicYear = 0
|
|
141
|
+
, moladDay = 0
|
|
142
|
+
, moladHalakim = 0
|
|
143
|
+
;
|
|
144
|
+
|
|
140
145
|
|
|
141
146
|
function GregorianToSdn(inputYear, inputMonth, inputDay) {
|
|
142
147
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
let year = 0
|
|
149
|
+
, month = 0
|
|
150
|
+
, sdn
|
|
151
|
+
;
|
|
146
152
|
|
|
147
153
|
// Make year a positive number
|
|
148
154
|
if (inputYear < 0) {
|
|
@@ -159,8 +165,8 @@ module.exports = function (inputDateOrYear, inputMonth, inputDate) {
|
|
|
159
165
|
year--;
|
|
160
166
|
}
|
|
161
167
|
|
|
162
|
-
sdn = Math.floor(Math.floor(year / 100) * DAYS_PER_400_YEARS / 4);
|
|
163
|
-
sdn += Math.floor(year % 100 * DAYS_PER_4_YEARS / 4);
|
|
168
|
+
sdn = Math.floor((Math.floor(year / 100) * DAYS_PER_400_YEARS) / 4);
|
|
169
|
+
sdn += Math.floor(((year % 100) * DAYS_PER_4_YEARS) / 4);
|
|
164
170
|
sdn += Math.floor((month * DAYS_PER_5_MONTHS + 2) / 5);
|
|
165
171
|
sdn += inputDay - GREG_SDN_OFFSET;
|
|
166
172
|
|
|
@@ -168,10 +174,11 @@ module.exports = function (inputDateOrYear, inputMonth, inputDate) {
|
|
|
168
174
|
}
|
|
169
175
|
|
|
170
176
|
function SdnToHebrew(sdn) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
177
|
+
let tishri1 = 0
|
|
178
|
+
, tishri1After = 0
|
|
179
|
+
, yearLength = 0
|
|
180
|
+
, inputDay = sdn - HEB_SDN_OFFSET
|
|
181
|
+
;
|
|
175
182
|
|
|
176
183
|
FindTishriMolad(inputDay);
|
|
177
184
|
tishri1 = Tishri1(metonicYear, moladDay, moladHalakim);
|
|
@@ -223,23 +230,28 @@ module.exports = function (inputDateOrYear, inputMonth, inputDate) {
|
|
|
223
230
|
if (mpy[(hebrewYear - 1) % 19] == 13) {
|
|
224
231
|
hebrewMonth = 7;
|
|
225
232
|
hebrewDate = inputDay - tishri1 + 207;
|
|
226
|
-
if (hebrewDate > 0)
|
|
233
|
+
if (hebrewDate > 0)
|
|
234
|
+
return;
|
|
227
235
|
hebrewMonth--;
|
|
228
236
|
hebrewDate += 30;
|
|
229
|
-
if (hebrewDate > 0)
|
|
237
|
+
if (hebrewDate > 0)
|
|
238
|
+
return;
|
|
230
239
|
hebrewMonth--;
|
|
231
240
|
hebrewDate += 30;
|
|
232
241
|
} else {
|
|
233
242
|
hebrewMonth = 6;
|
|
234
243
|
hebrewDate = inputDay - tishri1 + 207;
|
|
235
|
-
if (hebrewDate > 0)
|
|
244
|
+
if (hebrewDate > 0)
|
|
245
|
+
return;
|
|
236
246
|
hebrewMonth--;
|
|
237
247
|
hebrewDate += 30;
|
|
238
248
|
}
|
|
239
|
-
if (hebrewDate > 0)
|
|
249
|
+
if (hebrewDate > 0)
|
|
250
|
+
return;
|
|
240
251
|
hebrewMonth--;
|
|
241
252
|
hebrewDate += 29;
|
|
242
|
-
if (hebrewDate > 0)
|
|
253
|
+
if (hebrewDate > 0)
|
|
254
|
+
return;
|
|
243
255
|
// We need the length of the year to figure this out,so find Tishri 1 of this year.
|
|
244
256
|
tishri1After = tishri1;
|
|
245
257
|
FindTishriMolad(moladDay - 365);
|
|
@@ -290,7 +302,8 @@ module.exports = function (inputDateOrYear, inputMonth, inputDate) {
|
|
|
290
302
|
}
|
|
291
303
|
// Find the molad of Tishri closest to this date.
|
|
292
304
|
for (metonicYear = 0; metonicYear < 18; metonicYear++) {
|
|
293
|
-
if (moladDay > inputDay - 74)
|
|
305
|
+
if (moladDay > inputDay - 74)
|
|
306
|
+
break;
|
|
294
307
|
moladHalakim += HALAKIM_PER_LUNAR_CYCLE * mpy[metonicYear];
|
|
295
308
|
moladDay += Math.floor(moladHalakim / HALAKIM_PER_DAY);
|
|
296
309
|
moladHalakim = moladHalakim % HALAKIM_PER_DAY;
|
|
@@ -298,40 +311,43 @@ module.exports = function (inputDateOrYear, inputMonth, inputDate) {
|
|
|
298
311
|
}
|
|
299
312
|
|
|
300
313
|
function MoladOfMetonicCycle() {
|
|
301
|
-
|
|
302
|
-
r2 = void 0,
|
|
303
|
-
d1 = void 0,
|
|
304
|
-
d2 = void 0;
|
|
314
|
+
let r1, r2, d1, d2;
|
|
305
315
|
// Start with the time of the first molad after creation.
|
|
306
316
|
r1 = NEW_MOON_OF_CREATION;
|
|
307
317
|
// Calculate gMetonicCycle * HALAKIM_PER_METONIC_CYCLE. The upper 32
|
|
308
318
|
// bits of the result will be in r2 and the lower 16 bits will be in r1.
|
|
309
319
|
r1 += metonicCycle * (HALAKIM_PER_METONIC_CYCLE & 0xFFFF);
|
|
310
320
|
r2 = r1 >> 16;
|
|
311
|
-
r2 += metonicCycle * (HALAKIM_PER_METONIC_CYCLE >> 16 & 0xFFFF);
|
|
321
|
+
r2 += metonicCycle * ((HALAKIM_PER_METONIC_CYCLE >> 16) & 0xFFFF);
|
|
312
322
|
// Calculate r2r1 / HALAKIM_PER_DAY. The remainder will be in r1,the
|
|
313
323
|
// upper 16 bits of the quotient will be in d2 and the lower 16 bits
|
|
314
324
|
// will be in d1.
|
|
315
325
|
d2 = Math.floor(r2 / HALAKIM_PER_DAY);
|
|
316
326
|
r2 -= d2 * HALAKIM_PER_DAY;
|
|
317
|
-
r1 = r2 << 16 | r1 & 0xFFFF;
|
|
327
|
+
r1 = (r2 << 16) | (r1 & 0xFFFF);
|
|
318
328
|
d1 = Math.floor(r1 / HALAKIM_PER_DAY);
|
|
319
329
|
r1 -= d1 * HALAKIM_PER_DAY;
|
|
320
|
-
moladDay = d2 << 16 | d1;
|
|
330
|
+
moladDay = (d2 << 16) | d1;
|
|
321
331
|
moladHalakim = r1;
|
|
322
332
|
}
|
|
323
333
|
|
|
324
334
|
function Tishri1(metonicYear, moladDay, moladHalakim) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
335
|
+
let tishri1 = moladDay
|
|
336
|
+
, dow = tishri1 % 7
|
|
337
|
+
, leapYear = metonicYear == 2 || metonicYear == 5 || metonicYear == 7 || metonicYear == 10
|
|
338
|
+
|| metonicYear == 13 || metonicYear == 16 || metonicYear == 18
|
|
339
|
+
, lastWasLeapYear = metonicYear == 3 || metonicYear == 6 || metonicYear == 8 || metonicYear == 11
|
|
340
|
+
|| metonicYear == 14 || metonicYear == 17 || metonicYear == 0
|
|
341
|
+
;
|
|
329
342
|
|
|
330
343
|
// Apply rules 2,3 and 4
|
|
331
|
-
if (moladHalakim >= NOON ||
|
|
344
|
+
if ((moladHalakim >= NOON) ||
|
|
345
|
+
((!leapYear) && dow == TUES && moladHalakim >= AM3_11_20) ||
|
|
346
|
+
(lastWasLeapYear && dow == MON && moladHalakim >= AM9_32_43)) {
|
|
332
347
|
tishri1++;
|
|
333
348
|
dow++;
|
|
334
|
-
if (dow == 7)
|
|
349
|
+
if (dow == 7)
|
|
350
|
+
dow = 0;
|
|
335
351
|
}
|
|
336
352
|
|
|
337
353
|
// Apply rule 1 after the others because it can cause an additional delay of one day.
|
|
@@ -342,9 +358,9 @@ module.exports = function (inputDateOrYear, inputMonth, inputDate) {
|
|
|
342
358
|
return tishri1;
|
|
343
359
|
}
|
|
344
360
|
|
|
345
|
-
|
|
361
|
+
let inputYear = inputDateOrYear;
|
|
346
362
|
|
|
347
|
-
if (
|
|
363
|
+
if (typeof inputYear === "object") {
|
|
348
364
|
inputMonth = inputDateOrYear.getMonth() + 1;
|
|
349
365
|
inputDate = inputDateOrYear.getDate();
|
|
350
366
|
inputYear = inputDateOrYear.getFullYear();
|
|
@@ -353,9 +369,9 @@ module.exports = function (inputDateOrYear, inputMonth, inputDate) {
|
|
|
353
369
|
SdnToHebrew(GregorianToSdn(inputYear, inputMonth, inputDate));
|
|
354
370
|
|
|
355
371
|
return {
|
|
356
|
-
year: hebrewYear
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
372
|
+
year: hebrewYear
|
|
373
|
+
, month: hebrewMonth
|
|
374
|
+
, date: hebrewDate
|
|
375
|
+
, month_name: hMonth[hebrewMonth - 1]
|
|
360
376
|
};
|
|
361
|
-
};
|
|
377
|
+
};
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"correspondant"
|
|
13
13
|
],
|
|
14
14
|
"license": "MIT",
|
|
15
|
-
"version": "1.0.
|
|
15
|
+
"version": "1.0.8",
|
|
16
16
|
"main": "lib/index.js",
|
|
17
17
|
"scripts": {
|
|
18
18
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"cli.js",
|
|
31
31
|
"index.js",
|
|
32
32
|
"index.d.ts",
|
|
33
|
-
"package-lock.json",
|
|
34
33
|
"bloggify.js",
|
|
35
34
|
"bloggify.json",
|
|
36
35
|
"bloggify/"
|