jcal-zmanim 1.2.2 → 1.2.3
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/README.md +597 -0
- package/package.json +4 -5
package/README.md
ADDED
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
# jcal-zmanim
|
|
2
|
+
A very complete JavaScript library for the Jewish Calendar.
|
|
3
|
+
### To add *jcal-zmanim* to your project
|
|
4
|
+
> *npm install jcal-zmanim*
|
|
5
|
+
|
|
6
|
+
OR
|
|
7
|
+
|
|
8
|
+
> *yarn add jcal-zmanim*
|
|
9
|
+
|
|
10
|
+
### Some basic uses of *jcal-zmanim*
|
|
11
|
+
##### Print out todays Jewish Date
|
|
12
|
+
```javascript
|
|
13
|
+
import {jDate} from "jcal-zmanim";
|
|
14
|
+
|
|
15
|
+
const today = jDate.now();
|
|
16
|
+
console.log(today.toString());
|
|
17
|
+
```
|
|
18
|
+
The above code prints out:
|
|
19
|
+
> Thursday, the 23rd of Kislev 5784
|
|
20
|
+
##### Get the *Daf Yomi* for today
|
|
21
|
+
```javascript
|
|
22
|
+
import {jDate} from "jcal-zmanim";
|
|
23
|
+
|
|
24
|
+
//Prints out todays daf: "Baba Kamma, Daf 6"
|
|
25
|
+
console.log(jDate.now().getDafYomi());
|
|
26
|
+
```
|
|
27
|
+
##### Print out the sunrise and sunset times for 11/10/23 in Dallas
|
|
28
|
+
```javascript
|
|
29
|
+
import {jDate, findLocation, Utils} from "jcal-zmanim";
|
|
30
|
+
|
|
31
|
+
//Get the Jewish Date for November 10th, 2023.
|
|
32
|
+
const jd = new jDate("November 10 2023");
|
|
33
|
+
|
|
34
|
+
//Gets us Dallas Texas...
|
|
35
|
+
const dallas = findLocation('Dallas');
|
|
36
|
+
|
|
37
|
+
//Acquire the sunrise and sunset times for this date in Dallas
|
|
38
|
+
const {sunrise, sunset} = jd.getSunriseSunset(dallas);
|
|
39
|
+
|
|
40
|
+
//Print it out nicely formatted to the console
|
|
41
|
+
console.log(`In ${dallas.Name} on ${jd.toString()}, Sunrise is at ${Utils.getTimeString(sunrise)}, and Sunset is at ${Utils.getTimeString(sunset)}`);
|
|
42
|
+
```
|
|
43
|
+
The code above prints out to the console:
|
|
44
|
+
>In Dallas, TX on Erev Shabbos, the 26th of Cheshvan 5784, Sunrise is at 6:53:36 AM, and Sunset is at 5:28:59 PM
|
|
45
|
+
|
|
46
|
+
##### Get your age and the date of your next Jewish Birthday
|
|
47
|
+
```javascript
|
|
48
|
+
import {jDate, Utils} from 'jcal-zmanim'
|
|
49
|
+
|
|
50
|
+
//We start with the date of birth
|
|
51
|
+
const myDateOfBirth = new Date("July 18 1995")
|
|
52
|
+
|
|
53
|
+
//Get the Jewish Date for that wonderful day
|
|
54
|
+
const jewishDob = new jDate(myDateOfBirth)
|
|
55
|
+
|
|
56
|
+
//Get your age today (in the Jewish calendar)
|
|
57
|
+
const age = jewishDob.diffFullYears(jDate.now())
|
|
58
|
+
|
|
59
|
+
//Get the next birthday in Jewish
|
|
60
|
+
const nextBirthday = jewishDob.addYears(age + 1)
|
|
61
|
+
|
|
62
|
+
//Get the next birthday as a Date
|
|
63
|
+
const nextBirthdayDate = nextBirthday.getDate();
|
|
64
|
+
|
|
65
|
+
//Print it out
|
|
66
|
+
console.log(`Your jewish Birthday is the ${Utils.toSuffixed(jewishDob.Day)} day of ${JewishMonthsEng[jewishDob.Month]}.
|
|
67
|
+
On ${Utils.toStringDate(nextBirthdayDate)} you will become ${age + 1} in Jewish.`);
|
|
68
|
+
```
|
|
69
|
+
The code above prints out to the console:
|
|
70
|
+
>Your Jewish Birthday is the 20th day of Tamuz.
|
|
71
|
+
>On Wednesday, the 16th of July 2025 you will become 29 in Jewish.
|
|
72
|
+
|
|
73
|
+
##### Get the current Jewish Date in Hong Kong - taking into consideration that it may be after sunset there right now.
|
|
74
|
+
```javascript
|
|
75
|
+
import {findLocation, jDate, Utils} from 'jcal-zmanim'
|
|
76
|
+
|
|
77
|
+
//Get Hong Kong
|
|
78
|
+
const hongKong= findLocation('Hong Kong');
|
|
79
|
+
|
|
80
|
+
//Get the Jewish Date right now in Hong Kong
|
|
81
|
+
const nowInHongKong = Utils.nowAtLocation(hongKong);
|
|
82
|
+
|
|
83
|
+
//Print it out
|
|
84
|
+
console.log(nowInHongKong.toString());
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
##### Print out the candle lighting time for Dallas Texas on Friday November 10th 2023:
|
|
88
|
+
```javascript
|
|
89
|
+
import {jDate, findLocation, Utils} from "jcal-zmanim";
|
|
90
|
+
|
|
91
|
+
//Get the Jewish Date for Friday, the 10th of November, 2023.
|
|
92
|
+
const erevShabbos = new jDate("November 10 2023");
|
|
93
|
+
|
|
94
|
+
//Get Dallas...
|
|
95
|
+
const dallas = findLocation('Dallas');
|
|
96
|
+
|
|
97
|
+
//Get the candle-lighting time
|
|
98
|
+
const candles = erevShabbos.getCandleLighting(dallas);
|
|
99
|
+
|
|
100
|
+
//Spit in out formatted nicely...
|
|
101
|
+
console.log(`Candle lighting time in ${dallas.Name} on ${erevShabbos.toString()} is at ${Utils.getTimeString(candles)}`);
|
|
102
|
+
```
|
|
103
|
+
The code above, prints out to the console:
|
|
104
|
+
> Candle lighting time in Dallas, TX on Erev Shabbos, the 26th of Cheshvan 5784 is at 5:10:59 PM
|
|
105
|
+
---------------------------
|
|
106
|
+
## The jDate object
|
|
107
|
+
|
|
108
|
+
A *jDate* is a single day in the Jewish Calendar.<br>
|
|
109
|
+
It is used as the basic date unit throughout jcal-zmanim.
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
import {jDate} from "jcal-zmanim"
|
|
113
|
+
|
|
114
|
+
//The following will create a Jewish Date object for todays Date.
|
|
115
|
+
const jdate = new jDate();
|
|
116
|
+
|
|
117
|
+
//The following will output the above Jewish Date in the format: Thursday, the 3rd of Kislev 5784.
|
|
118
|
+
console.log(jdate.toString());
|
|
119
|
+
```
|
|
120
|
+
### Creating a jDate instance
|
|
121
|
+
A jDate can be created in a number of ways:
|
|
122
|
+
#### Create a jDate using the jDate constructor
|
|
123
|
+
- `const jdate = new jDate()` - Sets the Jewish Date for the current system date
|
|
124
|
+
- `const jdate = new jDate(javascriptDateObject)` - Sets to the Jewish date on the given Gregorian date
|
|
125
|
+
- `const jdate = new jDate("January 1 2045")` - Accepts any valid javascript Date string (uses JavaScript's new Date(string))
|
|
126
|
+
- `const jdate = new jDate(jewishYear, jewishMonth, jewishDay)` - Months start at 1. Nissan is month 1 Adar Sheini is 13.
|
|
127
|
+
- `const jdate = new jDate(jewishYear, jewishMonth)` - Same as above, with Day defaulting to 1
|
|
128
|
+
- `const jdate = new jDate( { year: 5776, month: 4, day: 5 } )` - same as new jDate(jewishYear, jewishMonth, jewishDay)
|
|
129
|
+
- `const jdate = new jDate( { year: 5776, month: 4 } )` - same as new jDate(jewishYear, jewishMonth)
|
|
130
|
+
- `const jdate = new jDate( { year: 5776 } )` - sets to the first day of Rosh Hashana on the given year
|
|
131
|
+
- `const jdate = new jDate(absoluteDate)` - The number of days elapsed since the theoretical date Sunday, December 31, 0001 BCE
|
|
132
|
+
- `const jdate = new jDate(jewishYear, jewishMonth, jewishDay, absoluteDate)` - Most efficient constructor. Needs no calculations at all.
|
|
133
|
+
- `const jdate = new jDate( { year: 5776, month: 4, day: 5, abs: 122548708 } )` - same as new jDate(jewishYear, jewishMonth, jewishDay, absoluteDate)
|
|
134
|
+
|
|
135
|
+
#### Create a jDate using the static *toJDate* function
|
|
136
|
+
|
|
137
|
+
- `jDate.toJDate()` OR `jDate.now()` - To get the current Jewish Date.
|
|
138
|
+
```javascript
|
|
139
|
+
//To print out the current Jewish Date in English.
|
|
140
|
+
console.log(jDate.toJDate().toString());
|
|
141
|
+
//A shortcut to get the current jDate.
|
|
142
|
+
const currentJDate = jDate.now();
|
|
143
|
+
//To print out the current Jewish Date in Hebrew:
|
|
144
|
+
console.log(jDate.now().toStringHeb());
|
|
145
|
+
```
|
|
146
|
+
- `jDate.toJDate(Date)` - Sets to the Jewish date on the given Javascript Date object
|
|
147
|
+
- `jDate.toJDate("January 1 2045")` - Accepts any valid Javascript Date string (uses string constructor of Date object)
|
|
148
|
+
```javascript
|
|
149
|
+
//To print out the Jewish Date for January 3rd 2026.
|
|
150
|
+
console.log(jDate.toJDate(new Date(2026, 0, 3)).toString());
|
|
151
|
+
|
|
152
|
+
//To print out the Jewish Date for March 23rd 2027:
|
|
153
|
+
console.log(jDate.toJDate('March 23 2027').toString());
|
|
154
|
+
```
|
|
155
|
+
- `jDate.toJDate(jewishYear, jewishMonth, jewishDay)` - Months start at 1. *Nissan* is month 1, and *Adar Sheini* is 13.
|
|
156
|
+
```javascript
|
|
157
|
+
//To print out the Jewish Date for the 6th day of Kislev 5785 in Hebrew:
|
|
158
|
+
console.log(jDate.toJDate(5785, 11, 6).toStringHeb());
|
|
159
|
+
//Prints out: יום שלישי ו שבט תשפ"ה
|
|
160
|
+
```
|
|
161
|
+
- `jDate.toJDate(jewishYear, jewishMonth)` - Same as above, with Day defaulting to 1
|
|
162
|
+
- `jDate.toJDate(jewishYear)` - sets to the first day of *Rosh Hashana* on the given year
|
|
163
|
+
- `jDate.toJDate( { year: 5776, month: 4, day: 5 } )` - Months start at 1. Nissan is month 1 Adara Sheini is 13.
|
|
164
|
+
- `jDate.toJDate( { year: 5776, month: 4 } )` - Same as above, with Day defaulting to 1
|
|
165
|
+
- `jDate.toJDate( { year: 5776 } )` - sets to the first day of *Rosh Hashana* on the given year
|
|
166
|
+
- `jDate.toJDate(jewishYear, jewishMonth, jewishDay, absoluteDate)` - Most efficient. Needs no calculations at all. The absoluteDate is the number of days elapsed since the theoretical date Sunday, December 31, 0001 BCE.
|
|
167
|
+
- `jDate.toJDate( { year: 5776, month: 4, day: 5, abs: 122548708 } ) `- same as `jDate.toJDate(jewishYear, jewishMonth, jewishDay, absoluteDate)`
|
|
168
|
+
------------------------------------------------------------------
|
|
169
|
+
### jDate instance, properties and functions
|
|
170
|
+
|
|
171
|
+
| Property | Return Type | Description |
|
|
172
|
+
| ---: | :---: | :--- |
|
|
173
|
+
| **Day** | `number` | The day of the Jewish month. Starts from 1. Maximum can be 29 or 30. |
|
|
174
|
+
| **Month** | `number` | The month of the Jewish year. Nissan is month number 1 and Adar Sheini is 13. |
|
|
175
|
+
| **Year** | `number` |The Jewish year. Valid values are 1 - 6000 |
|
|
176
|
+
| **Abs** | `number` | The number of days elapsed since the theoretical date Sunday, December 31, 0001 BCE. |
|
|
177
|
+
| **DayOfWeek** |`number`| The day of the week for the current Jewish date. Sunday is 0 and *Shabbos* is 6.<br>**Helpful tip**: Use the `DaysOfWeek` enum to compare days of the week.<br>For example:<br> `if(jdate.DayOfWeek === DaysOfWeek.FRIDAY) {`<br> `console.log('Today is Erev Shabbos!')`<br>`}` |
|
|
178
|
+
| **getDate()** | `Date` | Returns the javascript Date of this jDate.<br />This represents the Gregorian date that starts at midnight of the current Jewish Date. |
|
|
179
|
+
| **toString(hideDayOfWeek?, dontCapitalize?)** | `string` | Returns the current Jewish date in the format: "*Thursday, the 3rd of Kislev 5776*".<br />If *hideDayOfWeek* is truthy, the day of the week is left out.<br />If *dontCapitalize* is truthy and *hideDayOfWeek* is truthy, the 't' of "The 3rd etc." will be a regular 't', otherwise it will be a 'T'. This parameter has no effect when *hideDayOfWeek* is falsey. |
|
|
180
|
+
| **toShortstring(showDayOfWeek?)**| `string` | Returns the current Jewish date in the format "*Nissan 3, 5778*".<br />If showDayOfWeek is truthy, "*Tuesday Nissan 3, 5778*" is returned. |
|
|
181
|
+
|**toStringHeb()**|`string`|Returns the current Jewish date in the format:<br />*"יום חמישי כ"א כסלו תשע"ו"*|
|
|
182
|
+
| **addDays(numberOfDays)** | `jDate` | Returns a new Jewish Date by adding the given number of days to the current Jewish date.<br><br>Here is a nice trick that can be used to get the upcoming Shabbos:<br>-------------<br>`import {jDate, DaysOfWeek} from "jcal-zmanim";`<br>`const now = jDate.now();`<br>`const shabbos = now.addDays(DaysOfWeek.SHABBOS - (now.DayOfWeek % DaysOfWeek.SHABBOS));`<br>-------------<br>This can be used for any upcoming day - just substitute the DaysOfWeek you need.|
|
|
183
|
+
| **addMonths(numberOfMonths)** | `jDate` | Returns a new Jewish date by adding the given number of Jewish Months to the current Jewish date.<br />If the current Day is 30 and the new month only has 29 days, the 29th day of the month is returned. |
|
|
184
|
+
| **addYears(numberOfYears)** | `jDate` | Returns a new Jewish date represented by adding the given number of Jewish Years to the current Jewish date.<br />If the current Day is 30 and the new dates month only has 29 days, the 29th day of the month is returned. |
|
|
185
|
+
| **addSecularMonths(numberOfMonths)** | `jDate` | Adds the given number of months to the Secular Date of this jDate and returns the result as a jDate |
|
|
186
|
+
| **addSecularYears(numberOfYears)** | `jDate` | Adds the given number of years to the Secular Date of this jDate and returns the result as a jDate |
|
|
187
|
+
| **diffDays(otherJDate)** | `number` | Gets the number of days separating this Jewish Date and the given one.<br />If the given date is before this one, the number will be negative. |
|
|
188
|
+
| **diffMonths(otherJDate)** | `number` | Gets the number of months separating this Jewish Date and the given one.<br /> Ignores the Day property:<br />`jDate.toJDate(5777, 6, 29).diffMonths(jDate.toJDate(5778, 7, 1))`<br />will return 1 even though they are a day apart.<br />If the given date is before this one, the number will be negative. |
|
|
189
|
+
|**diffFullMonths(otherDate)**|`number`|Gets the number of full months separating this Jewish Date and the given one.<br>If the given date is before this one, the number will be negative.|
|
|
190
|
+
| **diffYears(otherJDate)** | `number` | Gets the number of years separating this Jewish Date and the given one.<br /> Ignores the Day and Month properties:<br /> `jDate.toJDate(5777, 6, 29).diffYears(jDate.toJDate(5778, 7, 1))` will return 1 even though they are a day apart.<br/> If the given date is before this one, the number will be negative. |
|
|
191
|
+
|diffFullYears(otherDate)|`number`|Use this function to calculate someones age.<br>Gets the number of full years separating this Jewish Date and the given one.<br>If the given date is before this one, the number will be negative.|
|
|
192
|
+
| **monthName(showYear? [=true])** | `string` | Returns the current Jewish date in the format "*Nissan 5778*".<br />If *showYear* === false, than just "*Nissan*" is returned. |
|
|
193
|
+
|**getDayOfOmer()**|`number`|Gets the day of the omer for the current Jewish date. If the date is not during *sefira*, 0 is returned.|
|
|
194
|
+
|**isYomTovOrCholHamoed(inIsrael?)**|`boolean`|Returns true if this day is *yomtov* or *chol hamoed*<br />If *inIsrael* is truthy, then the function will keep 1 day of *yomtov*.|
|
|
195
|
+
|**isYomTov(inIsrael?)**|`boolean`|Returns true if this day is *yomtov*.<br />If *inIsrael* is truthy, then the function will keep 1 day of *yomtov*.|
|
|
196
|
+
| **isErevYomTov()**|`boolean`|Is this day *Erev Yom Tov*? (includes *Erev* second days of *Sukkos* and *Pesach*)|
|
|
197
|
+
|**hasCandleLighting()**|`boolean`|Does the current Jewish date have candle lighting before sunset?<br />Note, on Friday that is *Yomtov*, this will return true.<br />For *Shabbos* when *Yomtov* is on Sunday, this will return false, as candles cannot be lit until after *Shabbos* is over.|
|
|
198
|
+
|**hasEiruvTavshilin(inIsrael?)**|boolean|Is the current Jewish Date the day before a *Yomtov* that contains a Friday?|
|
|
199
|
+
|**getCandleLighting([location](#the-location-object), nullIfNoCandles?)**|`{hour: 10, minute: 36, second: 15}`|Gets the candle lighting time for the current Jewish date for the given [Location](#the-location-object).<br />If the current day does not have candle lighting:<ul><li>If *nullIfNoCandles* is truthy, _null_ is returned.<li>Otherwise, a string is returned: *"No candle lighting on Thursday, the 3rd of Kislev 5776"*</ul>|
|
|
200
|
+
|**getSedra(inIsrael?)**|[Sedra](#the-sedra-object)|Get the [*Sedra*](#the-sedra-object) of the week for the current Jewish date.|
|
|
201
|
+
| **getPirkeiAvos(inIsrael?)** |`number[]`|Gets the *Prakim* of *Pirkei Avos* for the current *Shabbos*.<br/> If the current jDate is not Shabbos, or is during the winter months - where there is no *Pirkei Avos*, an empty array is returned.|
|
|
202
|
+
|**getSunriseSunset([location](#the-location-object), ignoreElevation?)**|`{sunrise: {hour: 6, minute: 18}, sunset: {hour: 19, minute: 41}}`|Gets sunrise and sunset time for the current Jewish date at the given [Location](#the-location-object).<br>If *ignoreElevation* is true, the calculations used to determine the sunrise and sunset, will assume that the Location is at sea level.<br>This is necessary for determining some of the daily *Zmanim*.|
|
|
203
|
+
| **getChatzos([location](#the-location-object))**|`{hour: 11, minute: 48}`|Gets Chatzos for both the day and the night for the current Jewish date at the given [Location](#the-location-object).|
|
|
204
|
+
|**getShaaZmanis**([location](#the-location-object), offset)|`number`|Gets the length in minutes for a single *Sha'a Zmanis* for the current Jewish date at the given [Location](#the-location-object).<br />By default, a *Sha'a Zmanis* is the total number of minutes from sunrise to sunset divided by 12.<br />To calculate from 72 minutes before sunrise to 72 minutes after sunset, set the *offset* parameter to 72.|
|
|
205
|
+
|**getDafYomi()**|`string`|Returns the daily daf in English. For example: "*Sukkah, Daf 3*".|
|
|
206
|
+
|**getDafyomiHeb()**|`string`|Gets the daily daf in Hebrew. For example:<br />*"'סוכה דף כ"*|
|
|
207
|
+
------------------------------------------------------------------
|
|
208
|
+
### jDate static properties and functions
|
|
209
|
+
| Property | Return Type | Description |
|
|
210
|
+
| ---: | :---: | :--- |
|
|
211
|
+
|[**jDate.toJDate(....)**](#create-a-jdate-using-the-static-tojdate-function)|`jDate`|[See all parameter options here...](#create-a-jdate-using-the-static-tojdate-function)|
|
|
212
|
+
|**jDate.now()**|`jDate`|Returns the current jDate. Shortcut for `jDate.toJDate()`|
|
|
213
|
+
|**jDate.fromAbs(absoluteDate)**|`jDate`|Calculates the Jewish Date for the given absolute date.<br />The absoluteDate is the number of days elapsed since the theoretical date Sunday, December 31, 0001 BCE.|
|
|
214
|
+
|**jDate.absSd(Date)**|`number`|Gets the absolute date of the given javascript Date object.|
|
|
215
|
+
|**jDate.absJd(jewishYear, jewishMonth, jewishDay)**|`number`|Calculate the absolute date for the given Jewish Date.<br>For the *jewishMonth*, *Nissan* is 1 and *Adar Sheini* is 13.|
|
|
216
|
+
|**jDate.sdFromAbs(absoluteDate)**|`Date`|Gets a javascript Date from an absolute date.|
|
|
217
|
+
|**jDate.daysJMonth(jewishYear, jewishMonth)**|`number`|The number of days in the given Jewish Month.<br>*Nissan* is 1 and *Adar Sheini* is 13.|
|
|
218
|
+
|**jDate.daysJYear(jewishYear)**|`number`|The number of days in the given Jewish Year.|
|
|
219
|
+
|**jDate.isLongCheshvan(jewishYear)**|`boolean`|Does *Cheshvan* for the given Jewish Year have 30 days?|
|
|
220
|
+
|**jDate.isShortKislev(jewishYear)** |`boolean`|Does Kislev for the given Jewish Year have 29 days?|
|
|
221
|
+
|**jDate.isJdLeapY(jewishYear)**|`boolean`|Does the given Jewish Year have 13 months?|
|
|
222
|
+
|**jDate.monthsJYear(jewishYear)**|`number`|The number of months in the given Jewish Year.|
|
|
223
|
+
------------------------------------------------------------------
|
|
224
|
+
## The Location Object
|
|
225
|
+
|
|
226
|
+
The city or location.<br>
|
|
227
|
+
This is very important for calculating any *Zmanim*, as sunset and sunrise are different for every city.<br>
|
|
228
|
+
In addition, there are different *Minhagim* in different cities.<br>A major example of this would be, in Eretz Yisroel, one day of *Yom Tov* is observed, while everywhere else, two days are kept.
|
|
229
|
+
|
|
230
|
+
##### To acquire the entire list of Locations:
|
|
231
|
+
```javascript
|
|
232
|
+
import {Locations} from "jcal-zmanim";
|
|
233
|
+
|
|
234
|
+
//Prints out the entire list of all 1,288 Location objects
|
|
235
|
+
for(let location of Locations) {
|
|
236
|
+
console.log(location);
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
### Finding a Location
|
|
240
|
+
|
|
241
|
+
##### To search for a Location object for anywhere in the world, import and use the `findLocation` function.
|
|
242
|
+
```javascript
|
|
243
|
+
import {findLocation} from "jcal-zmanim";
|
|
244
|
+
|
|
245
|
+
//By city name
|
|
246
|
+
const myCity = findLocation('Jersusalem');
|
|
247
|
+
|
|
248
|
+
//Or in Hebrew
|
|
249
|
+
const myCityHebrew = findLocation('ירושלים');
|
|
250
|
+
|
|
251
|
+
//Or by coordinates
|
|
252
|
+
const cityByCoords = findLocation({latitude: 31.77, longitude: -35.23});
|
|
253
|
+
|
|
254
|
+
//The coordinates do not have to be exact. The function will find the closest Location to the given coordinates.
|
|
255
|
+
const closeToJerusalem = findLocation({latitude: 31.75, longitude: -35.2});
|
|
256
|
+
```
|
|
257
|
+
##### There are 2 ways to search for a Location:
|
|
258
|
+
- `const location = findLocation(locationName)` - Finds a Location with the given name.<br />If no exact match is found, the location with the name most similar to the supplied locationName will be returned.<br>**Note:** The algorithm for this is fairly imprecise, so check to make sure that you have acquired the correct location.<br />If the location is in Israel, typing the name in Hebrew may help find the Location.
|
|
259
|
+
- `const location = findLocation(locationCoordinates)` - find a Location by supplying the coordinates in the format: `{latitude: 31.5, longitude: -32.54}`. The numbers are degree decimals.<br /> For latitude, North is a positive number and South is a negative number.<br /> For longitude, West is a positive number, and East is a negative number.<br /> If no Location is found with those exact coordinates, the Location closest to the supplied coordinates is returned.
|
|
260
|
+
|
|
261
|
+
### Location properties and functions
|
|
262
|
+
| Property | Return Type | Description |
|
|
263
|
+
| ---: | :---: | :--- |
|
|
264
|
+
|**Name**|`string`|The name of the Location.|
|
|
265
|
+
|**NameHebrew**|`string`|The name of the Location in Hebrew. Only available for Locations in Israel.|
|
|
266
|
+
|**Israel**|`boolean`|Is this Location in Israel?|
|
|
267
|
+
|**Latitude**|`number`|The *degree decimal* for the Locations latitude.<br>North is a positive number and South is a negative number.|
|
|
268
|
+
|**Longitude**|`number`|The *degree decimal* for the Locations longitude.<br>West is a positive number and East is a negative number.|
|
|
269
|
+
|**UTCOffset**|`number`|The time zone. Israel is 2 and New York is -5.|
|
|
270
|
+
|**Elevation**|`number`|Elevation in meters.<br>To convert from meters to feet, each meter is 3.2808 feet. |
|
|
271
|
+
|**CandleLighting**|`number`|Number of minutes before sunset the candles are lit on Friday|
|
|
272
|
+
|**Location.getJerusalem()**|`Location`|Static function that gets us the Location for Yerushalayim.|
|
|
273
|
+
|**Location.getLakewood()**|`Location`|Static function that gets us the Location for Lakewood NJ.|
|
|
274
|
+
|
|
275
|
+
### Creating a new Location
|
|
276
|
+
##### To create a Location for anywhere in the world, use the Location object constructor:
|
|
277
|
+
```javascript
|
|
278
|
+
import {Location} from "jcal-zmanim";
|
|
279
|
+
|
|
280
|
+
const myLocation = new Location(
|
|
281
|
+
'Nowhere', // The location name
|
|
282
|
+
'יהופיץ', //The name in Hebrew.
|
|
283
|
+
false, // This place is not in Israel
|
|
284
|
+
35.01 // The latitude. North is positive.
|
|
285
|
+
-155.23, // The longitude. East is negative.
|
|
286
|
+
11, // The Time Zone: The number of hours offset from UTC.
|
|
287
|
+
1106, // The elevation in Meters. (Feet x 3.2808)
|
|
288
|
+
18) // The number of minutes before sunset candles are lit on Erev Shabbos.
|
|
289
|
+
);
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
----------------------------------
|
|
293
|
+
|
|
294
|
+
## Zmanim
|
|
295
|
+
The following functions can be used to get *Halachic Zmanim* for any date, anywhere.
|
|
296
|
+
##### To get the daily Sunset, Sunrise and *Chatzos* for any location in the world:
|
|
297
|
+
```javascript
|
|
298
|
+
import {findLocation, jDate} from "jcal-zmanim";
|
|
299
|
+
|
|
300
|
+
//The following code gets Sunset, Sunrise and Chatzos for Lakewood NJ on Purim 5789.
|
|
301
|
+
|
|
302
|
+
const lakewood = findLocation('Lakewood');
|
|
303
|
+
const purim = new jDate(5789,12, 14);
|
|
304
|
+
const {sunset, sunrise} = purim.getSunriseSunset(lakewood);
|
|
305
|
+
const chatzos = purim.getChatzos(lakewood);
|
|
306
|
+
|
|
307
|
+
console.log(`Sunset: ${Utils.getTimeString(sunset)}`);
|
|
308
|
+
console.log(`Sunrise: ${Utils.getTimeString(sunrise)}`);
|
|
309
|
+
console.log(`chatzos: ${Utils.getTimeString(chatzos)}`);
|
|
310
|
+
```
|
|
311
|
+
The code above prints out:
|
|
312
|
+
>Sunset: 5:49:02 PM<br>
|
|
313
|
+
>Sunrise: 6:29:49 AM<br>
|
|
314
|
+
>chatzos: 12:09:25 PM
|
|
315
|
+
|
|
316
|
+
##### To get <u>all</u> the *Halachic Zmanim* for a given day and Location:
|
|
317
|
+
```javascript
|
|
318
|
+
import {findLocation, jDate, ZmanimUtils, Utils} from 'jcal-zmanim';
|
|
319
|
+
|
|
320
|
+
const lakewood = findLocation('Lakewood');
|
|
321
|
+
const purim = new jDate(5789,12, 14);
|
|
322
|
+
|
|
323
|
+
//This will return an array of Zmanim in the format:
|
|
324
|
+
//[{zmanType:{eng, heb}, time: {hour, minute, second}}]
|
|
325
|
+
const allZmanim = ZmanimUtils.getAllZmanim(purim, lakewood);
|
|
326
|
+
|
|
327
|
+
for(let zman of allZmanim) {
|
|
328
|
+
console.log(`${zman.zmanType.eng}: ${Utils.getTimeString(zman.time)}`)
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
The code above prints out:
|
|
332
|
+
> Chatzos - Midnight: 12:09:25 AM<br>
|
|
333
|
+
> Alos Hashachar - 90: 4:59:49 AM<br>
|
|
334
|
+
> Alos Hashachar - 72: 5:17:49 AM<br>
|
|
335
|
+
> Taliss and Tefillin: 5:53:49 AM<br>
|
|
336
|
+
> Sunrise at current elevation: 6:29:49 AM<br>
|
|
337
|
+
> Sunrise: 6:29:49 AM<br>
|
|
338
|
+
> Zman Krias Shma - MG"A: 8:33:49 AM<br>
|
|
339
|
+
> Zman Krias Shma - GR"A: 9:18:49 AM<br>
|
|
340
|
+
> Zman Tefilla - MG"A: 9:45:49 AM<br>
|
|
341
|
+
> Zman Tefilla - GR"A: 10:15:49 AM<br>
|
|
342
|
+
> Chatzos - Midday: 12:09:25 PM<br>
|
|
343
|
+
> Mincha Gedola: 12:37:25 PM<br>
|
|
344
|
+
> Mincha Ketana: 3:26:49 PM<br>
|
|
345
|
+
> Plag HaMincha: 4:37:49 PM<br>
|
|
346
|
+
> Sunset at sea level: 5:49:02 PM<br>
|
|
347
|
+
> Sunset: 5:49:02 PM<br>
|
|
348
|
+
> Nightfall - 45: 6:34:02 PM<br>
|
|
349
|
+
> Nightfall - 50: 6:39:02 PM<br>
|
|
350
|
+
> Rabbeinu Tam: 7:01:02 PM<br>
|
|
351
|
+
> Rabbeinu Tam - Zmanios: 6:56:02 PM<br>
|
|
352
|
+
> Rabbeinu Tam - Zmanios MG"A: 7:14:02 PM
|
|
353
|
+
##### To get just the basic daily *Halachic Zmanim* for a given day and Location:
|
|
354
|
+
```javascript
|
|
355
|
+
import {findLocation, jDate, ZmanimUtils, Utils} from 'jcal-zmanim';
|
|
356
|
+
|
|
357
|
+
const lakewood = findLocation('Lakewood');
|
|
358
|
+
const purim = new jDate(5789,12, 14);
|
|
359
|
+
|
|
360
|
+
//This will return an array of Zmanim in the format:
|
|
361
|
+
//[{zmanType:{eng, heb}, time: {hour, minute, second}}]
|
|
362
|
+
const someZmanim = ZmanimUtils.getBasicShulZmanim(purim, lakewood);
|
|
363
|
+
|
|
364
|
+
for(let zman of someZmanim) {
|
|
365
|
+
console.log(`${zman.zmanType.eng}: ${Utils.getTimeString(zman.time)}`)
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
The code above prints out:
|
|
369
|
+
> Chatzos - Midday: 12:09:25 PM<br>
|
|
370
|
+
> Alos Hashachar - 90: 4:59:49 AM<br>
|
|
371
|
+
> Sunset: 5:49:02 PM<br>
|
|
372
|
+
> Candle lighting time: 5:31:02 PM
|
|
373
|
+
|
|
374
|
+
### Zmanim Types
|
|
375
|
+
The ZmanTypes enum can be acquired by importing `ZmanTypeIds` from 'jcal-zmanim'.<br>
|
|
376
|
+
If you need to print out the Zman Type description etc., use the `getZmanType` function.
|
|
377
|
+
|
|
378
|
+
Here is a list of the in-built *Zmanim Types*:
|
|
379
|
+
|
|
380
|
+
|ZmanTypeId|Description|English|Hebrew|
|
|
381
|
+
| ---: | :--- | :--- | :--- |
|
|
382
|
+
| `ZmanTypeIds.ChatzosLayla` |חצות הלילה|Chatzos - Midnight|חצות הלילה|
|
|
383
|
+
| `ZmanTypeIds.Alos90`|עלות השחר - 90 דקות|Alos Hashachar - 90|עלות השחר (90)|
|
|
384
|
+
| `ZmanTypeIds.Alos72`|עלות השחר - 72 דקות|Alos Hashachar - 72|עלות השחר (72)|
|
|
385
|
+
| `ZmanTypeIds.TalisTefillin`|זמן עטיפת טלית ותפילין - 36 דקות|Taliss and Tefillin|טלית ותפילין|
|
|
386
|
+
| `ZmanTypeIds.NetzAtElevation`|הנץ החמה בגובה המיקום|Sunrise at current elevation|הנץ החמה - מגובה|
|
|
387
|
+
| `ZmanTypeIds.NetzMishor`|הנץ החמה בגובה פני הים|Sunrise|הנץ החמה|
|
|
388
|
+
| `ZmanTypeIds.szksMga`|סזק"ש מג"א|Zman Krias Shma - MG"A|סזק"ש מג"א|
|
|
389
|
+
| `ZmanTypeIds.szksGra`|סזק"ש הגר"א|Zman Krias Shma - GR"A|סזק"ש הגר"א|
|
|
390
|
+
| `ZmanTypeIds.sztMga`|סז"ת מג"א|Zman Tefilla - MG"A|סז"ת מג"א|
|
|
391
|
+
| `ZmanTypeIds.sztGra`|סז"ת הגר"א|Zman Tefilla - GR"A|סז"ת הגר"א|
|
|
392
|
+
| `ZmanTypeIds.chatzosDay`|חצות היום|Chatzos - Midday|חצות היום|
|
|
393
|
+
| `ZmanTypeIds.minGed`|מנחה גדולה|Mincha Gedola|מנחה גדולה|
|
|
394
|
+
| `ZmanTypeIds.minKet`|מנחה קטנה|Mincha Ketana|מנחה קטנה|
|
|
395
|
+
| `ZmanTypeIds.plag`|פלג המנחה|Plag HaMincha|פלג המנחה|
|
|
396
|
+
| `ZmanTypeIds.shkiaAtSeaLevel`|שקיעת החמה מגובה פני הים|Sunset at sea level|שקיעת החמה - ממישור|
|
|
397
|
+
| `ZmanTypeIds.shkiaElevation`|שקיעת החמה מגובה המיקום|Sunset|שקיעת החמה|
|
|
398
|
+
| `ZmanTypeIds.tzais45`|45 דקות אחרי שקיעה|Nightfall - 45|צאת הכוכבים (45)|
|
|
399
|
+
| `ZmanTypeIds.tzais50`|50 דקות אחרי שקיעה|Nightfall - 50|צאת הכוכבים (50)|
|
|
400
|
+
| `ZmanTypeIds.tzais72`|72 דקות אחרי שקיעה|Rabbeinu Tam|צה"כ ר"ת - 72 דקות|
|
|
401
|
+
| `ZmanTypeIds.rabbeinuTamZmanios`|72 דקות זמניות אחרי שקיעה|Rabbeinu Tam - Zmanios|צה"כ ר"ת - זמניות|
|
|
402
|
+
| `ZmanTypeIds.rabbeinuTamZmaniosMga`|72 דקות זמניות אחרי שקיעה - מג"א|Rabbeinu Tam - Zmanios MG"A|צה"כ ר"ת - זמניות מג"א|
|
|
403
|
+
| `ZmanTypeIds.candleLighting`|זמן הדלקת נרות|Candle lighting time|זמן הדלקת נרות|
|
|
404
|
+
| `ZmanTypeIds.SofZmanEatingChometz`|סוף זמן אכילת חמץ|Stop eating Chometz|סוף זמן אכילת חמץ|
|
|
405
|
+
| `ZmanTypeIds.SofZmanBurnChometz`|סוף זמן ביעור חמץ|Destroy Chometz|סוף זמן ביעור חמץ|
|
|
406
|
+
##### To get a list of particular Zmanim:
|
|
407
|
+
```javascript
|
|
408
|
+
import {jDate, findLocation, ZmanimUtils, ZmanTypeIds, getZmanType} from 'jcal-zmanim';
|
|
409
|
+
|
|
410
|
+
//Get Lakewood, NJ
|
|
411
|
+
const lakewood = findLocation('Lakewood');
|
|
412
|
+
|
|
413
|
+
//Get the Jewish Date of Purim 5789
|
|
414
|
+
const purim = new jDate(5789,12, 14);
|
|
415
|
+
|
|
416
|
+
//Here is a list of the Zmanim Types we want
|
|
417
|
+
const zmanimTypesWeWant= [
|
|
418
|
+
getZmanType(ZmanTypeIds.Alos72),
|
|
419
|
+
getZmanType(ZmanTypeIds.chatzosDay),
|
|
420
|
+
getZmanType(ZmanTypeIds.shkiaElevation)
|
|
421
|
+
];
|
|
422
|
+
|
|
423
|
+
//This will return an array of these Zmanim in the format:
|
|
424
|
+
//[{zmanType:{eng, heb}, time: {hour, minute, second}}]
|
|
425
|
+
const zmanimForThose = ZmanimUtils.getZmanTimes(
|
|
426
|
+
zmanimTypesWeWant,
|
|
427
|
+
purim.getDate(),
|
|
428
|
+
purim,
|
|
429
|
+
lakewood
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
//Print them out nicely
|
|
433
|
+
for(let zman of zmanimForThose) {
|
|
434
|
+
console.log(`${zman.zmanType.eng}: ${Utils.getTimeString(zman.time)}`)
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
### Calculate other Zmanim
|
|
438
|
+
To calculate any other *Zman*, add the number of minutes or *Shaas Zmanimios* to sunset, sunrise or *Chatzos*.
|
|
439
|
+
##### For example, to calculate 4 *Shaos Zmanios* of the *Magen Avraham* after sunrise in Lakewood NJ on Purim 5789:
|
|
440
|
+
```javascript
|
|
441
|
+
import {jDate, findLocation, Utils} from 'jcal-zmanim';
|
|
442
|
+
|
|
443
|
+
//Get Lakewood, NJ
|
|
444
|
+
const lakewood = findLocation('Lakewood');
|
|
445
|
+
|
|
446
|
+
//Get the Jewish Date of Purim 5789
|
|
447
|
+
const purim = new jDate(5789, 12, 14);
|
|
448
|
+
|
|
449
|
+
//Get Hanetz Hachama
|
|
450
|
+
const {sunrise} = purim.getSunriseSunset(lakewood);
|
|
451
|
+
|
|
452
|
+
//Get the longer Shaos Zmanios length for this day -
|
|
453
|
+
//from 72 minutes before sunrise until 72 minutes after sunset
|
|
454
|
+
const shaosZmanios = purim.getShaaZmanis(lakewood, 72);
|
|
455
|
+
|
|
456
|
+
//Add 4 long Shaos Zmanios to Hanetz Hachama (Why not? it's Purim...)
|
|
457
|
+
const lateZman = Utils.addMinutes(sunrise, shaosZmanios * 4);
|
|
458
|
+
|
|
459
|
+
//Print it out nicely
|
|
460
|
+
console.log(`Hanetz on Purim 5789 in Lakewood is: ${Utils.getTimeString(sunrise)}\n4 long Sha'os Zmanios after Hanetz is :) ${Utils.getTimeString(lateZman)}`)
|
|
461
|
+
```
|
|
462
|
+
The code above prints out:
|
|
463
|
+
>Hanetz on Purim 5789 in Lakewood is: 6:29:49 AM<br>
|
|
464
|
+
>4 long Sha'os Zmanios after Hanetz is :) 11:03:49 AM
|
|
465
|
+
|
|
466
|
+
---------------------
|
|
467
|
+
|
|
468
|
+
## The Sedra Object
|
|
469
|
+
The *Sedra* object is obtained by calling getSedra on a [jDate](#the-jdate-object).
|
|
470
|
+
|
|
471
|
+
```javascript
|
|
472
|
+
import {jDate} from "jcal-zmanim";
|
|
473
|
+
|
|
474
|
+
const today = jDate.now();
|
|
475
|
+
|
|
476
|
+
//Gets the sedra for today out of Israel
|
|
477
|
+
const parsha = today.getSedra(false);
|
|
478
|
+
|
|
479
|
+
//Print that out
|
|
480
|
+
console.log(parsha.toString());
|
|
481
|
+
```
|
|
482
|
+
The above code printed out:
|
|
483
|
+
>Chayei Sara
|
|
484
|
+
|
|
485
|
+
#### Sedra Property and Functions:
|
|
486
|
+
|Name|Type|Description|
|
|
487
|
+
| ---: | :---: |:--- |
|
|
488
|
+
| **sedras** |`[{eng, heb}]`|An array for the `Sedra` of the week for the current [jDate](#the-jdate-object).<br>Each item in the array contains the `eng` (English) name of that *parsha* and `heb`, the Hebrew name.|
|
|
489
|
+
|**toString()**|`string`|Gets the sedra/s names in English as a string. If there are two, they are seperated by a " - "|
|
|
490
|
+
|**toStringHeb()**|`string`|Gets the sedra/s names in Hebrew as a string. If there are two, they are seperated by a " - "|
|
|
491
|
+
|
|
492
|
+
------------------------------------------
|
|
493
|
+
## The Molad Functions
|
|
494
|
+
|Name|Type|Description|
|
|
495
|
+
| ---: | :---: |:--- |
|
|
496
|
+
| **Molad.getMolad(jewishMonth, jewishYear)** |`{jDate,time,chalakim}`|Gets the *Molad* for the given Jewish Year and Month.<br>For the Month, Nissan is 1 and Adar Sheini is 13.<br>The returned object contains the [jDate](#the-jdate-object), the time of day in the format `{hour, minute}` and the number of *Chalakim*|
|
|
497
|
+
|**Molad.getString(jewishYear, jewishMonth)**|`string`|Gets the *Molad* for the given Jewish Year and Month.<br>For the Month, Nissan is 1 and Adar Sheini is 13.<br>Returns the time of the molad as a string in the format: *Monday Night, 8:33 PM and 12 Chalakim*.<br>The molad is always in Jerusalem so we use the Jerusalem sunset times to determine whether to display "Night" or *Motzai Shabbos* etc.|
|
|
498
|
+
|**Molad.getStringHeb(jewishYear, jewishMonth)**|`string`|Gets the *Molad* for the given Jewish Year and Month.<br>For the Month, Nissan is 1 and Adar Sheini is 13.<br>Returns the time of the molad as a string in the format: *ליל שני 20:33 12 חלקים* <br>The molad is always in Jerusalem so we use the Jerusalem sunset times to determine whether to display "ליל/יום" or "מוצאי שב"ק" etc.|
|
|
499
|
+
------------------------------------
|
|
500
|
+
## Daily *Notifications* and *Shul Notifications*
|
|
501
|
+
Get a list of Halacha related information about any [jDate](#the-jdate-object).<br>
|
|
502
|
+
This is very useful for creating an application that shows the daily information and *Zmanim* in a *Shul* etc.
|
|
503
|
+
<br>
|
|
504
|
+
To get these notifications, use the *getNotifications* function.
|
|
505
|
+
|
|
506
|
+
#### There are two lists that are returned from the *getNotifications* function.
|
|
507
|
+
- **Daily Notifications** - These are information about the given day, such as if it is Shabbos or YomTov, the *Daf Yomi*, day of *Sefirah* etc.
|
|
508
|
+
- **Shul Notifications** - These are *shul* and *davening* realted information about the given day, such as the *Torah* reading, skipping *Tachnun*, saying *Hallel*, the *Shir Shel Yom* etc.
|
|
509
|
+
##### Sample use of daily and *tefillah* notifications:
|
|
510
|
+
```javascript
|
|
511
|
+
import {jDate, getNotifications, findLocation} from "jcal-zmanim";
|
|
512
|
+
|
|
513
|
+
//Get Lakewood NJ
|
|
514
|
+
const lakewood = findLocation('Lakewood');
|
|
515
|
+
|
|
516
|
+
//Get Purim 5784
|
|
517
|
+
const purim = new jDate(5784, 13, 14);
|
|
518
|
+
|
|
519
|
+
//We want to get the notifications that are relevant at 8 o'clock in the morning.
|
|
520
|
+
const morningTime = { hour:8, minute:0 };
|
|
521
|
+
|
|
522
|
+
//Get Purim's notifications
|
|
523
|
+
const {dayNotes, tefillahNotes} = getNotifications(purim, morningTime, lakewood, true, true, true);
|
|
524
|
+
|
|
525
|
+
//Print them out
|
|
526
|
+
console.log(`Purim: ${purim.toString()}\nDaily Notes:\n\t${dayNotes.join('\n\t')}\nTefillah Notes:\n\t${tefillahNotes.join('\n\t')}`);
|
|
527
|
+
```
|
|
528
|
+
The above code prints out:
|
|
529
|
+
> Purim: Sunday, the 14th of Adar Sheini 5784<br>
|
|
530
|
+
> Daily Notes:
|
|
531
|
+
> - Megilas Esther
|
|
532
|
+
> - Purim
|
|
533
|
+
> - Baba Metzia Daf 25
|
|
534
|
+
>
|
|
535
|
+
> Tefillah Notes:
|
|
536
|
+
> - No Laminatzeach
|
|
537
|
+
> - Al Hanissim
|
|
538
|
+
> - שיר של יום - כ"ב - למנצח על אילת השחר
|
|
539
|
+
> - No Tachnun
|
|
540
|
+
### The **getNotifications** Function - parameters
|
|
541
|
+
|Parameter|Type|Description|
|
|
542
|
+
|-----:|:-------:|:--------|
|
|
543
|
+
|**date**|`Date` or `jDate`|Either a jDate or a javascript Date|
|
|
544
|
+
|**time**|`{hour, minute}}`|The time of day for which to show notifications for. <br>For example, "Hallel" will not be shown at night etc.|
|
|
545
|
+
|**location**|`Location`|Where in the world to show notifications for?|
|
|
546
|
+
|**english**|`boolean`|Should the notifications be in English or Hebrew?|
|
|
547
|
+
|**showGaonShir**|`boolean`|Should the *Shir Shel Yom* of the Gr"a be shown?<br>If this paremeter is undefined, it will not be shown, unless the location is in Israel.|
|
|
548
|
+
|**showDafYomi**|`boolean`|Should the daily *Daf* be shown in the daily notifications?<br>Defaults to **true**.|
|
|
549
|
+
|
|
550
|
+
------------------------------------------
|
|
551
|
+
## The Utils Functions
|
|
552
|
+
The Utils Class contains many useful jDate and regular Date functions.<br>
|
|
553
|
+
It also has some extremely useful general functions.
|
|
554
|
+
|
|
555
|
+
|Function|Return Type|Description|
|
|
556
|
+
|-----:|:-------:|:--------|
|
|
557
|
+
|**Utils.toJewishNumber(number)**|`string`|Gets the Jewish representation of a number (365 = שס"ה)<br>Minimum number is 1 and maximum is 9999.|
|
|
558
|
+
|**Utils.toStringDate(Date, hideDayOfWeek?, dontCapitalize?)**|`string`|Returns the javascript date in the format: Thursday, the 3rd of January 2018.|
|
|
559
|
+
|**Utils.toShortStringDate(Date, monthFirst?)**|`string`|Returns the javascript date in the format: 132020.|
|
|
560
|
+
|**Utils.toSuffixed(number)**|`string`|Add two character suffix to number. e.g. 21st, 102nd, 93rd, 500th|
|
|
561
|
+
|**Utils.isSecularLeapYear(year)**|`boolean`|Returns if the given full secular year has a February 29th|
|
|
562
|
+
|**Utils.getSdDOW(year, month, day)**|`number`|Get day of week using Javascripts getDay function.<br>Important note: months starts at 1 not 0 like javascript<br>The DOW returned has Sunday = 0|
|
|
563
|
+
|**Utils.fixTime(Time)**|`{hour, minute, second}`|Makes sure hour is between 0 and 23 and minute is between 0 and 59.<br>Overlaps get addedsubtracted.<br>The argument needs to be an object in the format {hour : 12, minute : 42, second : 18}|
|
|
564
|
+
|**Utils.addMinutes(Time, minutes)**|`{hour, minute, second}`|Add the given number of minutes to the given time.<br>The argument needs to be an object in the format {hour : 12, minute : 42, second : 18 }|
|
|
565
|
+
|**Utils.addSeconds(Time, seconds)**|`{hour, minute, second}`|Add the given number of seconds to the given time.<br>The argument needs to be an object in the format {hour : 12, minute :42, second : 18}|
|
|
566
|
+
|**Utils.timeDiff(earlierTime, laterTime, showNegative?)**|`{hour, minute, second, sign}`|Gets the time difference between two times of day.<br>If showNegative is falsey, assumes that the earlier time is always before the later time.<br>So, if laterTime is less than earlierTime, the returned diff is until the next day.<br>Both arguments need to be an object in the format {hour : 12, minute : 42, second : 18 }|
|
|
567
|
+
|**Utils.totalMinutes(Time)**|`number`|Gets the total number of minutes in the given time. |
|
|
568
|
+
|**Utils.totalSeconds(Time)**|`number`|Gets the total number of seconds in the given time. |
|
|
569
|
+
|**Utils.timeFromDate(Date)**|`{hour, minute, second}`|Returns the time of the given javascript date.|
|
|
570
|
+
|**Utils.isTimeAfter(beforeTime, afterTime)**|`boolean`|Determines if the second given time is after (or at) the first given time|
|
|
571
|
+
|**Utils.getTimeIntervalTextStringHeb(Time)**|`string`|Returns the given time interval in a formatted string.|
|
|
572
|
+
|**Utils.getTimeIntervalTextString(Time)**|`string`|Returns the given time interval in a formatted string.|
|
|
573
|
+
|**Utils.getTimeString(Time, sign?, army?, roundUp?)**|`string`|Returns the given time in a formatted string.|
|
|
574
|
+
|**Utils.getOmerNusach(dayOfOmer, nusach)**|`string`|Returns the nusach for Sefiras Ha'omer for the given day and minhag<br>The *nusach* parameter should be either *'ashkenaz'* or *'sefard'* or *'sefardi'*)|
|
|
575
|
+
|**Utils.currUtcOffset()**|`number`|Gets the UTC offset in whole hours for the users time zone.<br>Note: this is not affected by DST - unlike javascripts getTimezoneOffset() function which gives you the current offset.|
|
|
576
|
+
|**Utils.isDateDST( Date)**|`boolean`|Determines if the given date is within DST on the users system|
|
|
577
|
+
|**Utils.isDST(Location, Date)**|`boolean`|Determines if the given date is within DST in the given location<br>Note: This may not be correct if the user has set the Location to a time zone outside Israel or the USA which is not the current system time zone.|
|
|
578
|
+
|**Utils.isUSA_DST(date: Date)**|`boolean`|Determines if the given javascript date is during DST according to the USA rules|
|
|
579
|
+
|**Utils.isIsrael_DST(date: Date)**|`boolean`|Determines if the given Javascript date is during DST according to the current (5776) Israeli rules|
|
|
580
|
+
|**Utils.getSdNowInIsrael()**|`Date`|The current time in Israel - determined by the current users system time and time zone offset|
|
|
581
|
+
|**Utils.addDaysToSdate(Date, days)**|`Date`|Adds the given number of days to the given javascript Date and returns the new date |
|
|
582
|
+
|**Utils.isSameSdate(Date1, Date2)**|`boolean`|Compares two js dates to se if they both refer to the same day - time is ignored.|
|
|
583
|
+
|**Utils.isSameJdate(jDate1, jDate2)**|`boolean`|Compares two jDates to se if they both refer to the same day - time is ignored.|
|
|
584
|
+
|**Utils.isSameJMonth(jDate1, jDate2)**|`boolean`|Compares two jDates to see if they both refer to the same Jewish Month.|
|
|
585
|
+
|**Utils.isSameSMonth(Date1, Date2)**|`boolean`|Compares two javascript dates to see if they both refer to the same Secular Month.|
|
|
586
|
+
|**Utils.isAfterSunset(Date, Location)**|`boolean`|Determines if the time of the given Date() is after sunset at the given Location|
|
|
587
|
+
|**Utils.nowAtLocation(Location)**|`jDate`|Gets the current Jewish Date at the given Location|
|
|
588
|
+
|**Utils.toInt(float)**|`number`|Converts the given complex number to an integer by removing the decimal part.<br>Returns same results as Math.floor for positive numbers and Math.ceil for negative ones.<br>Almost identical functionality to Math.trunc and parseInt.<br>The difference is if the argument is NaN. Math.trunc returns NaN while ths fuction returns 0.<br>In performance tests, this function was found to be quicker than the alternatives.|
|
|
589
|
+
|**Utils.bothDates(Date)**|`{ sdate:Date, jdate:jDate }`|Takes either a jDate or a Date and returns both|
|
|
590
|
+
|**Utils.isString(thing)**|`boolean`|Returns true if "thing" is either a string primitive or String object.|
|
|
591
|
+
|**Utils.isNumber(thing)**|`boolean`|Returns true if "thing" is either a number primitive or a Number object.|
|
|
592
|
+
|**Utils.isValidDate(thing)**|`boolean`|Returns true if "thing" is a Date object containing a valid date.|
|
|
593
|
+
|**Utils.has(thing, ...paramsOrArrayOrString)**|`boolean`|Returns whether or not the given, array, string, or argument list contains the given item or substring.<br>This function is awfully similar to Array.includes, but has the added plus of accepting any number or type of arguments.|
|
|
594
|
+
|**Utils.setDefault(paramValue, defValue)**|`any`|Returns the first value unless it is undefined, null or NaN.<br>This is very useful for boolean, string and integer parameters<br>where we want to keep false, "" and 0 if they were supplied.<br>Similar purpose to default parameters with the difference being that this function will return the second value if the first is NaN or null, while default params will give give you the NaN or the null.|
|
|
595
|
+
|**Utils.log(string, ...optionalItems)**||Log message to console|
|
|
596
|
+
|**Utils.warn(string, ...optionalItems)**||Warn message to console|
|
|
597
|
+
|**Utils.error(string, ...optionalItems)**||Error message to console|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jcal-zmanim",
|
|
3
3
|
"description": "A very complete JavaScript library for the Jewish Calendar, Zmanim, Holidays, and daily Shul notes.",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.3",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -13,16 +13,15 @@
|
|
|
13
13
|
"@swc/core": "1.3.96",
|
|
14
14
|
"@types/jest": "^29.5.8",
|
|
15
15
|
"@types/node": "20.8.10",
|
|
16
|
-
"copyfiles": "^2.4.1",
|
|
17
16
|
"jest": "^29.7.0",
|
|
18
|
-
"
|
|
17
|
+
"shx": "^0.3.4",
|
|
19
18
|
"tsup": "7.3.0",
|
|
20
19
|
"typescript": "^5.2.2"
|
|
21
20
|
},
|
|
22
21
|
"scripts": {
|
|
23
22
|
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
24
|
-
"build": "
|
|
25
|
-
"build-win": "
|
|
23
|
+
"build": "NODE_ENV=production && tsup && && shx cp -r ./README.md dist/",
|
|
24
|
+
"build-win": "SET NODE_ENV=production && tsup && shx cp -r ./README.md dist/",
|
|
26
25
|
"build-dev": "NODE_ENV=development && tsup",
|
|
27
26
|
"build-dev-win": "SET NODE_ENV=development && tsup",
|
|
28
27
|
"tsup": "tsup"
|