@hebcal/noaa 0.8.8 → 0.8.10

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/dist/index.js CHANGED
@@ -15,25 +15,33 @@ function degreesToRadians(degrees) {
15
15
  function radiansToDegrees(radians) {
16
16
  return (radians * 180) / Math.PI;
17
17
  }
18
- const Long_MIN_VALUE = NaN;
19
18
  /**
20
19
  * A class that contains location information such as latitude and longitude required for astronomical calculations. The
21
- * elevation field may not be used by some calculation engines and would be ignored if set. Check the documentation for
22
- * specific implementations of the {@link AstronomicalCalculator} to see if elevation is calculated as part of the
23
- * algorithm.
20
+ * elevation field may not be used by some calculation engines and would be ignored if set.
24
21
  *
25
22
  * @author © Eliyahu Hershfeld 2004 - 2016
26
23
  * @version 1.1
27
24
  */
28
25
  export class GeoLocation {
29
- constructor(name, latitude, longitude, elevationOrTimeZoneId, timeZoneId) {
30
- let elevation = 0;
31
- if (timeZoneId) {
32
- elevation = elevationOrTimeZoneId;
33
- }
34
- else {
35
- timeZoneId = elevationOrTimeZoneId;
36
- }
26
+ /**
27
+ * GeoLocation constructor with parameters for all required fields.
28
+ *
29
+ * @param {string} name
30
+ * The location name for display use such as "Lakewood, NJ"
31
+ * @param {number} latitude
32
+ * the latitude in a double format such as 40.095965 for Lakewood, NJ.
33
+ * <b>Note: </b> For latitudes south of the equator, a negative value should be used.
34
+ * @param {number} longitude
35
+ * double the longitude in a double format such as -74.222130 for Lakewood, NJ.
36
+ * <b>Note: </b> For longitudes west of the <a href="http://en.wikipedia.org/wiki/Prime_Meridian">Prime
37
+ * Meridian </a> (Greenwich), a negative value should be used.
38
+ * @param {number} elevation
39
+ * the elevation above sea level in Meters. Elevation is not used in most algorithms used for calculating
40
+ * sunrise and set.
41
+ * @param {string} timeZoneId
42
+ * the <code>TimeZone</code> for the location.
43
+ */
44
+ constructor(name, latitude, longitude, elevation, timeZoneId) {
37
45
  this.setLocationName(name);
38
46
  this.setLatitude(latitude);
39
47
  this.setLongitude(longitude);
@@ -42,34 +50,22 @@ export class GeoLocation {
42
50
  }
43
51
  /**
44
52
  * @private
45
- * @see #getLatitude()
46
- * @see #setLatitude(double)
47
- * @see #setLatitude(int, int, double, String)
48
53
  */
49
54
  latitude;
50
55
  /**
51
56
  * @private
52
- * @see #getLongitude()
53
- * @see #setLongitude(double)
54
- * @see #setLongitude(int, int, double, String)
55
57
  */
56
58
  longitude;
57
59
  /**
58
60
  * @private
59
- * @see #getLocationName()
60
- * @see #setLocationName(String)
61
61
  */
62
62
  locationName = null;
63
63
  /**
64
64
  * @private
65
- * @see #getTimeZone()
66
- * @see #setTimeZone(TimeZone)
67
65
  */
68
66
  timeZoneId;
69
67
  /**
70
68
  * @private
71
- * @see #getElevation()
72
- * @see #setElevation(double)
73
69
  */
74
70
  elevation;
75
71
  /**
@@ -84,9 +80,14 @@ export class GeoLocation {
84
80
  * Method to set the elevation in Meters <b>above </b> sea level.
85
81
  *
86
82
  * @param {number} elevation
87
- * The elevation to set in Meters. An IllegalArgumentException will be thrown if the value is a negative.
83
+ * The elevation to set in Meters. An Error will be thrown if the value is a negative.
88
84
  */
89
85
  setElevation(elevation) {
86
+ if (typeof elevation !== 'number')
87
+ throw new TypeError('Invalid elevation');
88
+ if (elevation < 0) {
89
+ throw new RangeError(`elevation ${elevation} must be zero or positive`);
90
+ }
90
91
  this.elevation = elevation;
91
92
  }
92
93
  setLatitude(latitude) {
@@ -137,13 +138,7 @@ export class GeoLocation {
137
138
  return this.timeZoneId;
138
139
  }
139
140
  /**
140
- * Method to set the TimeZone. If this is ever set after the GeoLocation is set in the
141
- * {@link AstronomicalCalendar}, it is critical that
142
- * {@link AstronomicalCalendar#getCalendar()}.
143
- * {@link java.util.Calendar#setTimeZone(TimeZone) setTimeZone(TimeZone)} be called in order for the
144
- * AstronomicalCalendar to output times in the expected offset. This situation will arise if the
145
- * AstronomicalCalendar is ever {@link AstronomicalCalendar#clone() cloned}.
146
- *
141
+ * Method to set the TimeZone.
147
142
  * @param {string} timeZoneId
148
143
  * The timeZone to set.
149
144
  */
@@ -185,14 +180,11 @@ const earthRadius = 6356.9; // in KM
185
180
  export class NOAACalculator {
186
181
  /**
187
182
  * A constructor that takes in <a href="http://en.wikipedia.org/wiki/Geolocation">geolocation</a> information as a
188
- * parameter. The default {@link AstronomicalCalculator#getDefault() AstronomicalCalculator} used for solar
189
- * calculations is the the {@link NOAACalculator}.
183
+ * parameter.
190
184
  *
191
185
  * @param {GeoLocation} geoLocation
192
186
  * The location information used for calculating astronomical sun times.
193
187
  * @param {Temporal.PlainDate} date
194
- *
195
- * @see #setAstronomicalCalculator(AstronomicalCalculator) for changing the calculator class.
196
188
  */
197
189
  constructor(geoLocation, date) {
198
190
  this.date = date;
@@ -210,8 +202,8 @@ export class NOAACalculator {
210
202
  * a point, and because the atmosphere refracts light, this 90&deg; zenith does not, in fact, correspond to true
211
203
  * sunset or sunrise, instead the center of the Sun's disk must lie just below the horizon for the upper edge to be
212
204
  * obscured. This means that a zenith of just above 90&deg; must be used. The Sun subtends an angle of 16 minutes of
213
- * arc (this can be changed via the {@link #setSunRadius(double)} method , and atmospheric refraction accounts for
214
- * 34 minutes or so (this can be changed via the {@link #setRefraction(double)} method), giving a total of 50
205
+ * arc, and atmospheric refraction accounts for
206
+ * 34 minutes or so, giving a total of 50
215
207
  * arcminutes. The total value for ZENITH is 90+(5/6) or 90.8333333&deg; for true sunrise/sunset.
216
208
  */
217
209
  // const ZENITH: number = GEOMETRIC_ZENITH + 5.0 / 6.0;
@@ -233,28 +225,27 @@ export class NOAACalculator {
233
225
  geoLocation;
234
226
  /**
235
227
  * The getSunrise method Returns a `Date` representing the
236
- * {@link AstronomicalCalculator#getElevationAdjustment(double) elevation adjusted} sunrise time. The zenith used
237
- * for the calculation uses {@link #GEOMETRIC_ZENITH geometric zenith} of 90&deg; plus
238
- * {@link AstronomicalCalculator#getElevationAdjustment(double)}. This is adjusted by the
239
- * {@link AstronomicalCalculator} to add approximately 50/60 of a degree to account for 34 archminutes of refraction
240
- * and 16 archminutes for the sun's radius for a total of {@link AstronomicalCalculator#adjustZenith 90.83333&deg;}.
241
- * See documentation for the specific implementation of the {@link AstronomicalCalculator} that you are using.
228
+ * {@link getElevationAdjustment elevation adjusted} sunrise time. The zenith used
229
+ * for the calculation uses {@link GEOMETRIC_ZENITH geometric zenith} of 90&deg; plus
230
+ * {@link getElevationAdjustment}. This is adjusted
231
+ * to add approximately 50/60 of a degree to account for 34 archminutes of refraction
232
+ * and 16 archminutes for the sun's radius for a total of {@link adjustZenith 90.83333&deg;}.
242
233
  *
243
234
  * @return {Temporal.ZonedDateTime | null} the `Date` representing the exact sunrise time. If the calculation can't be computed such as
244
235
  * in the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it
245
236
  * does not set, a null will be returned. See detailed explanation on top of the page.
246
- * @see AstronomicalCalculator#adjustZenith
247
- * @see #getSeaLevelSunrise()
248
- * @see AstronomicalCalendar#getUTCSunrise
237
+ * @see adjustZenith
238
+ * @see getSeaLevelSunrise()
239
+ * @see getUTCSunrise
249
240
  */
250
241
  getSunrise() {
251
242
  const sunrise = this.getUTCSunrise0(NOAACalculator.GEOMETRIC_ZENITH);
252
- if (Number.isNaN(sunrise))
243
+ if (isNaN(sunrise))
253
244
  return null;
254
245
  return this.getDateFromTime(sunrise, true);
255
246
  }
256
247
  /**
257
- * A method that returns the sunrise without {@link AstronomicalCalculator#getElevationAdjustment(double) elevation
248
+ * A method that returns the sunrise without {@link getElevationAdjustment elevation
258
249
  * adjustment}. Non-sunrise and sunset calculations such as dawn and dusk, depend on the amount of visible light,
259
250
  * something that is not affected by elevation. This method returns sunrise calculated at sea level. This forms the
260
251
  * base for dawn calculations that are calculated as a dip below the horizon before sunrise.
@@ -262,55 +253,55 @@ export class NOAACalculator {
262
253
  * @return {Temporal.ZonedDateTime | null} the `Date` representing the exact sea-level sunrise time. If the calculation can't be computed
263
254
  * such as in the Arctic Circle where there is at least one day a year where the sun does not rise, and one
264
255
  * where it does not set, a null will be returned. See detailed explanation on top of the page.
265
- * @see AstronomicalCalendar#getSunrise
266
- * @see AstronomicalCalendar#getUTCSeaLevelSunrise
267
- * @see #getSeaLevelSunset()
256
+ * @see getSunrise
257
+ * @see getUTCSeaLevelSunrise
258
+ * @see getSeaLevelSunset()
268
259
  */
269
260
  getSeaLevelSunrise() {
270
261
  const sunrise = this.getUTCSeaLevelSunrise(NOAACalculator.GEOMETRIC_ZENITH);
271
- if (Number.isNaN(sunrise))
262
+ if (isNaN(sunrise))
272
263
  return null;
273
264
  return this.getDateFromTime(sunrise, true);
274
265
  }
275
266
  /**
276
- * A method that returns the beginning of civil twilight (dawn) using a zenith of {@link #CIVIL_ZENITH 96&deg;}.
267
+ * A method that returns the beginning of civil twilight (dawn) using a zenith of {@link CIVIL_ZENITH 96&deg;}.
277
268
  *
278
269
  * @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of civil twilight using a zenith of 96&deg;. If the calculation
279
270
  * can't be computed, null will be returned. See detailed explanation on top of the page.
280
- * @see #CIVIL_ZENITH
271
+ * @see CIVIL_ZENITH
281
272
  */
282
273
  getBeginCivilTwilight() {
283
274
  return this.getSunriseOffsetByDegrees(NOAACalculator.CIVIL_ZENITH);
284
275
  }
285
276
  /**
286
- * A method that returns the beginning of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102&deg;}.
277
+ * A method that returns the beginning of nautical twilight using a zenith of {@link NAUTICAL_ZENITH 102&deg;}.
287
278
  *
288
279
  * @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of nautical twilight using a zenith of 102&deg;. If the
289
280
  * calculation can't be computed null will be returned. See detailed explanation on top of the page.
290
- * @see #NAUTICAL_ZENITH
281
+ * @see NAUTICAL_ZENITH
291
282
  */
292
283
  getBeginNauticalTwilight() {
293
284
  return this.getSunriseOffsetByDegrees(NOAACalculator.NAUTICAL_ZENITH);
294
285
  }
295
286
  /**
296
- * A method that returns the beginning of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH
287
+ * A method that returns the beginning of astronomical twilight using a zenith of {@link ASTRONOMICAL_ZENITH
297
288
  * 108&deg;}.
298
289
  *
299
290
  * @return {Temporal.ZonedDateTime | null} The `Date` of the beginning of astronomical twilight using a zenith of 108&deg;. If the
300
291
  * calculation can't be computed, null will be returned. See detailed explanation on top of the page.
301
- * @see #ASTRONOMICAL_ZENITH
292
+ * @see ASTRONOMICAL_ZENITH
302
293
  */
303
294
  getBeginAstronomicalTwilight() {
304
295
  return this.getSunriseOffsetByDegrees(NOAACalculator.ASTRONOMICAL_ZENITH);
305
296
  }
306
297
  /**
307
298
  * The getSunset method Returns a `Date` representing the
308
- * {@link AstronomicalCalculator#getElevationAdjustment(double) elevation adjusted} sunset time. The zenith used for
309
- * the calculation uses {@link #GEOMETRIC_ZENITH geometric zenith} of 90&deg; plus
310
- * {@link AstronomicalCalculator#getElevationAdjustment(double)}. This is adjusted by the
311
- * {@link AstronomicalCalculator} to add approximately 50/60 of a degree to account for 34 archminutes of refraction
312
- * and 16 archminutes for the sun's radius for a total of {@link AstronomicalCalculator#adjustZenith 90.83333&deg;}.
313
- * See documentation for the specific implementation of the {@link AstronomicalCalculator} that you are using. Note:
299
+ * {@link getElevationAdjustment elevation adjusted} sunset time. The zenith used for
300
+ * the calculation uses {@link GEOMETRIC_ZENITH geometric zenith} of 90&deg; plus
301
+ * {@link getElevationAdjustment}. This is adjusted
302
+ * to add approximately 50/60 of a degree to account for 34 archminutes of refraction
303
+ * and 16 archminutes for the sun's radius for a total of {@link adjustZenith 90.83333&deg;}.
304
+ * Note:
314
305
  * In certain cases the calculates sunset will occur before sunrise. This will typically happen when a timezone
315
306
  * other than the local timezone is used (calculating Los Angeles sunset using a GMT timezone for example). In this
316
307
  * case the sunset date will be incremented to the following date.
@@ -318,18 +309,18 @@ export class NOAACalculator {
318
309
  * @return {Temporal.ZonedDateTime | null} The `Date` representing the exact sunset time. If the calculation can't be computed such as in
319
310
  * the Arctic Circle where there is at least one day a year where the sun does not rise, and one where it
320
311
  * does not set, a null will be returned. See detailed explanation on top of the page.
321
- * @see AstronomicalCalculator#adjustZenith
322
- * @see #getSeaLevelSunset()
323
- * @see AstronomicalCalendar#getUTCSunset
312
+ * @see adjustZenith
313
+ * @see getSeaLevelSunset()
314
+ * @see getUTCSunset
324
315
  */
325
316
  getSunset() {
326
317
  const sunset = this.getUTCSunset0(NOAACalculator.GEOMETRIC_ZENITH);
327
- if (Number.isNaN(sunset))
318
+ if (isNaN(sunset))
328
319
  return null;
329
320
  return this.getDateFromTime(sunset, false);
330
321
  }
331
322
  /**
332
- * A method that returns the sunset without {@link AstronomicalCalculator#getElevationAdjustment(double) elevation
323
+ * A method that returns the sunset without {@link getElevationAdjustment elevation
333
324
  * adjustment}. Non-sunrise and sunset calculations such as dawn and dusk, depend on the amount of visible light,
334
325
  * something that is not affected by elevation. This method returns sunset calculated at sea level. This forms the
335
326
  * base for dusk calculations that are calculated as a dip below the horizon after sunset.
@@ -337,43 +328,43 @@ export class NOAACalculator {
337
328
  * @return {Temporal.ZonedDateTime | null} The `Date` representing the exact sea-level sunset time. If the calculation can't be computed
338
329
  * such as in the Arctic Circle where there is at least one day a year where the sun does not rise, and one
339
330
  * where it does not set, a null will be returned. See detailed explanation on top of the page.
340
- * @see AstronomicalCalendar#getSunset
341
- * @see AstronomicalCalendar#getUTCSeaLevelSunset 2see {@link #getSunset()}
331
+ * @see getSunset
332
+ * @see getUTCSeaLevelSunset
342
333
  */
343
334
  getSeaLevelSunset() {
344
335
  const sunset = this.getUTCSeaLevelSunset(NOAACalculator.GEOMETRIC_ZENITH);
345
- if (Number.isNaN(sunset))
336
+ if (isNaN(sunset))
346
337
  return null;
347
338
  return this.getDateFromTime(sunset, false);
348
339
  }
349
340
  /**
350
- * A method that returns the end of civil twilight using a zenith of {@link #CIVIL_ZENITH 96&deg;}.
341
+ * A method that returns the end of civil twilight using a zenith of {@link CIVIL_ZENITH 96&deg;}.
351
342
  *
352
- * @return {Temporal.ZonedDateTime | null} The `Date` of the end of civil twilight using a zenith of {@link #CIVIL_ZENITH 96&deg;}. If
343
+ * @return {Temporal.ZonedDateTime | null} The `Date` of the end of civil twilight using a zenith of {@link CIVIL_ZENITH 96&deg;}. If
353
344
  * the calculation can't be computed, null will be returned. See detailed explanation on top of the page.
354
- * @see #CIVIL_ZENITH
345
+ * @see CIVIL_ZENITH
355
346
  */
356
347
  getEndCivilTwilight() {
357
348
  return this.getSunsetOffsetByDegrees(NOAACalculator.CIVIL_ZENITH);
358
349
  }
359
350
  /**
360
- * A method that returns the end of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102&deg;}.
351
+ * A method that returns the end of nautical twilight using a zenith of {@link NAUTICAL_ZENITH 102&deg;}.
361
352
  *
362
- * @return {Temporal.ZonedDateTime | null} The `Date` of the end of nautical twilight using a zenith of {@link #NAUTICAL_ZENITH 102&deg;}
353
+ * @return {Temporal.ZonedDateTime | null} The `Date` of the end of nautical twilight using a zenith of {@link NAUTICAL_ZENITH 102&deg;}
363
354
  * . If the calculation can't be computed, null will be returned. See detailed explanation on top of the
364
355
  * page.
365
- * @see #NAUTICAL_ZENITH
356
+ * @see NAUTICAL_ZENITH
366
357
  */
367
358
  getEndNauticalTwilight() {
368
359
  return this.getSunsetOffsetByDegrees(NOAACalculator.NAUTICAL_ZENITH);
369
360
  }
370
361
  /**
371
- * A method that returns the end of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH 108&deg;}.
362
+ * A method that returns the end of astronomical twilight using a zenith of {@link ASTRONOMICAL_ZENITH 108&deg;}.
372
363
  *
373
- * @return {Temporal.ZonedDateTime | null} The `Date` of the end of astronomical twilight using a zenith of {@link #ASTRONOMICAL_ZENITH
364
+ * @return {Temporal.ZonedDateTime | null} The `Date` of the end of astronomical twilight using a zenith of {@link ASTRONOMICAL_ZENITH
374
365
  * 108&deg;}. If the calculation can't be computed, null will be returned. See detailed explanation on top
375
366
  * of the page.
376
- * @see #ASTRONOMICAL_ZENITH
367
+ * @see ASTRONOMICAL_ZENITH
377
368
  */
378
369
  getEndAstronomicalTwilight() {
379
370
  return this.getSunsetOffsetByDegrees(NOAACalculator.ASTRONOMICAL_ZENITH);
@@ -391,49 +382,49 @@ export class NOAACalculator {
391
382
  * @return {Temporal.ZonedDateTime | null} the `Date` with the offset in milliseconds added to it
392
383
  */
393
384
  static getTimeOffset(time, offset) {
394
- if (time === null || offset === Long_MIN_VALUE || Number.isNaN(offset)) {
385
+ if (time === null || isNaN(offset)) {
395
386
  return null;
396
387
  }
397
388
  return time.add({ milliseconds: offset });
398
389
  }
399
390
  /**
400
391
  * A utility method that returns the time of an offset by degrees below or above the horizon of
401
- * {@link #getSunrise() sunrise}. Note that the degree offset is from the vertical, so for a calculation of 14&deg;
402
- * before sunrise, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
392
+ * {@link getSunrise() sunrise}. Note that the degree offset is from the vertical, so for a calculation of 14&deg;
393
+ * before sunrise, an offset of 14 + {@link GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
403
394
  *
404
395
  * @param {number} offsetZenith
405
- * the degrees before {@link #getSunrise()} to use in the calculation. For time after sunrise use
396
+ * the degrees before {@link getSunrise} to use in the calculation. For time after sunrise use
406
397
  * negative numbers. Note that the degree offset is from the vertical, so for a calculation of 14&deg;
407
- * before sunrise, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a
398
+ * before sunrise, an offset of 14 + {@link GEOMETRIC_ZENITH} = 104 would have to be passed as a
408
399
  * parameter.
409
- * @return {Temporal.ZonedDateTime | null} The `Date` of the offset after (or before) {@link #getSunrise()}. If the calculation
400
+ * @return {Temporal.ZonedDateTime | null} The `Date` of the offset after (or before) {@link getSunrise}. If the calculation
410
401
  * can't be computed such as in the Arctic Circle where there is at least one day a year where the sun does
411
402
  * not rise, and one where it does not set, a null will be returned. See detailed explanation on top of the
412
403
  * page.
413
404
  */
414
405
  getSunriseOffsetByDegrees(offsetZenith) {
415
406
  const dawn = this.getUTCSunrise0(offsetZenith);
416
- if (Number.isNaN(dawn))
407
+ if (isNaN(dawn))
417
408
  return null;
418
409
  return this.getDateFromTime(dawn, true);
419
410
  }
420
411
  /**
421
- * A utility method that returns the time of an offset by degrees below or above the horizon of {@link #getSunset()
412
+ * A utility method that returns the time of an offset by degrees below or above the horizon of {@link getSunset()
422
413
  * sunset}. Note that the degree offset is from the vertical, so for a calculation of 14&deg; after sunset, an
423
- * offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
414
+ * offset of 14 + {@link GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
424
415
  *
425
416
  * @param {number} offsetZenith
426
- * the degrees after {@link #getSunset()} to use in the calculation. For time before sunset use negative
417
+ * the degrees after {@link getSunset} to use in the calculation. For time before sunset use negative
427
418
  * numbers. Note that the degree offset is from the vertical, so for a calculation of 14&deg; after
428
- * sunset, an offset of 14 + {@link #GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
429
- * @return {Temporal.ZonedDateTime | null} The `Date`of the offset after (or before) {@link #getSunset()}. If the calculation can't
419
+ * sunset, an offset of 14 + {@link GEOMETRIC_ZENITH} = 104 would have to be passed as a parameter.
420
+ * @return {Temporal.ZonedDateTime | null} The `Date`of the offset after (or before) {@link getSunset}. If the calculation can't
430
421
  * be computed such as in the Arctic Circle where there is at least one day a year where the sun does not
431
422
  * rise, and one where it does not set, a null will be returned. See detailed explanation on top of the
432
423
  * page.
433
424
  */
434
425
  getSunsetOffsetByDegrees(offsetZenith) {
435
426
  const sunset = this.getUTCSunset0(offsetZenith);
436
- if (Number.isNaN(sunset))
427
+ if (isNaN(sunset))
437
428
  return null;
438
429
  return this.getDateFromTime(sunset, false);
439
430
  }
@@ -445,7 +436,7 @@ export class NOAACalculator {
445
436
  * the degrees below the horizon. For time after sunrise use negative numbers.
446
437
  * @return {number} The time in the format: 18.75 for 18:45:00 UTC/GMT. If the calculation can't be computed such as in the
447
438
  * Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
448
- * not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
439
+ * not set, `NaN` will be returned. See detailed explanation on top of the page.
449
440
  */
450
441
  getUTCSunrise0(zenith) {
451
442
  return this.getUTCSunrise(this.getAdjustedDate(), this.geoLocation, zenith, true);
@@ -460,9 +451,9 @@ export class NOAACalculator {
460
451
  * the degrees below the horizon. For time after sunrise use negative numbers.
461
452
  * @return {number} The time in the format: 18.75 for 18:45:00 UTC/GMT. If the calculation can't be computed such as in the
462
453
  * Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
463
- * not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
464
- * @see AstronomicalCalendar#getUTCSunrise
465
- * @see AstronomicalCalendar#getUTCSeaLevelSunset
454
+ * not set, `NaN` will be returned. See detailed explanation on top of the page.
455
+ * @see getUTCSunrise
456
+ * @see getUTCSeaLevelSunset
466
457
  */
467
458
  getUTCSeaLevelSunrise(zenith) {
468
459
  return this.getUTCSunrise(this.getAdjustedDate(), this.geoLocation, zenith, false);
@@ -475,8 +466,8 @@ export class NOAACalculator {
475
466
  * the degrees below the horizon. For time after sunset use negative numbers.
476
467
  * @return {number} The time in the format: 18.75 for 18:45:00 UTC/GMT. If the calculation can't be computed such as in the
477
468
  * Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
478
- * not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
479
- * @see AstronomicalCalendar#getUTCSeaLevelSunset
469
+ * not set, `NaN` will be returned. See detailed explanation on top of the page.
470
+ * @see getUTCSeaLevelSunset
480
471
  */
481
472
  getUTCSunset0(zenith) {
482
473
  return this.getUTCSunset(this.getAdjustedDate(), this.geoLocation, zenith, true);
@@ -492,9 +483,9 @@ export class NOAACalculator {
492
483
  * the degrees below the horizon. For time before sunset use negative numbers.
493
484
  * @return {number} The time in the format: 18.75 for 18:45:00 UTC/GMT. If the calculation can't be computed such as in the
494
485
  * Arctic Circle where there is at least one day a year where the sun does not rise, and one where it does
495
- * not set, {@link Double#NaN} will be returned. See detailed explanation on top of the page.
496
- * @see AstronomicalCalendar#getUTCSunset
497
- * @see AstronomicalCalendar#getUTCSeaLevelSunrise
486
+ * not set, `NaN` will be returned. See detailed explanation on top of the page.
487
+ * @see getUTCSunset
488
+ * @see getUTCSeaLevelSunrise
498
489
  */
499
490
  getUTCSeaLevelSunset(zenith) {
500
491
  return this.getUTCSunset(this.getAdjustedDate(), this.geoLocation, zenith, false);
@@ -512,9 +503,9 @@ export class NOAACalculator {
512
503
  * Method to return the adjustment to the zenith required to account for the elevation. Since a person at a higher
513
504
  * elevation can see farther below the horizon, the calculation for sunrise / sunset is calculated below the horizon
514
505
  * used at sea level. This is only used for sunrise and sunset and not times before or after it such as
515
- * {@link AstronomicalCalendar#getBeginNauticalTwilight() nautical twilight} since those
506
+ * {@link getBeginNauticalTwilight() nautical twilight} since those
516
507
  * calculations are based on the level of available light at the given dip below the horizon, something that is not
517
- * affected by elevation, the adjustment should only made if the zenith == 90&deg; {@link #adjustZenith adjusted}
508
+ * affected by elevation, the adjustment should only made if the zenith == 90&deg; {@link adjustZenith adjusted}
518
509
  * for refraction and solar radius. The algorithm used is
519
510
  *
520
511
  * <pre>
@@ -546,30 +537,30 @@ export class NOAACalculator {
546
537
  * is not a point, and because the atmosphere refracts light, this 90&deg; zenith does not, in fact, correspond to
547
538
  * true sunset or sunrise, instead the centre of the Sun's disk must lie just below the horizon for the upper edge
548
539
  * to be obscured. This means that a zenith of just above 90&deg; must be used. The Sun subtends an angle of 16
549
- * minutes of arc (this can be changed via the {@link #setSolarRadius(double)} method , and atmospheric refraction
550
- * accounts for 34 minutes or so (this can be changed via the {@link #setRefraction(double)} method), giving a total
540
+ * minutes of arc, and atmospheric refraction
541
+ * accounts for 34 minutes or so, giving a total
551
542
  * of 50 arcminutes. The total value for ZENITH is 90+(5/6) or 90.8333333&deg; for true sunrise/sunset. Since a
552
543
  * person at an elevation can see blow the horizon of a person at sea level, this will also adjust the zenith to
553
544
  * account for elevation if available. Note that this will only adjust the value if the zenith is exactly 90 degrees.
554
545
  * For values below and above this no correction is done. As an example, astronomical twilight is when the sun is
555
- * 18&deg; below the horizon or {@link AstronomicalCalendar#ASTRONOMICAL_ZENITH 108&deg;
546
+ * 18&deg; below the horizon or {@link ASTRONOMICAL_ZENITH 108&deg;
556
547
  * below the zenith}. This is traditionally calculated with none of the above mentioned adjustments. The same goes
557
548
  * for various <em>tzais</em> and <em>alos</em> times such as the
558
549
  * {@link ZmanimCalendar#ZENITH_16_POINT_1 16.1&deg;} dip used in
559
- * {@link ComplexZmanimCalendar#getAlos16Point1Degrees()}.
550
+ * {@link ComplexZmanimCalendar#getAlos16Point1Degrees}.
560
551
  *
561
552
  * @param {number} zenith
562
- * the azimuth below the vertical zenith of 90&deg;. For sunset typically the {@link #adjustZenith
563
- * zenith} used for the calculation uses geometric zenith of 90&deg; and {@link #adjustZenith adjusts}
553
+ * the azimuth below the vertical zenith of 90&deg;. For sunset typically the {@link adjustZenith
554
+ * zenith} used for the calculation uses geometric zenith of 90&deg; and {@link adjustZenith adjusts}
564
555
  * this slightly to account for solar refraction and the sun's radius. Another example would be
565
- * {@link AstronomicalCalendar#getEndNauticalTwilight()} that passes
566
- * {@link AstronomicalCalendar#NAUTICAL_ZENITH} to this method.
556
+ * {@link getEndNauticalTwilight} that passes
557
+ * {@link NAUTICAL_ZENITH} to this method.
567
558
  * @param {number} elevation
568
559
  * elevation in Meters.
569
- * @return {number} The zenith adjusted to include the {@link #getSolarRadius sun's radius}, {@link #getRefraction
570
- * refraction} and {@link #getElevationAdjustment elevation} adjustment. This will only be adjusted for
560
+ * @return {number} The zenith adjusted to include the sun's radius, refracton
561
+ * and {@link getElevationAdjustment elevation} adjustment. This will only be adjusted for
571
562
  * sunrise and sunset (if the zenith == 90&deg;)
572
- * @see #getElevationAdjustment(double)
563
+ * @see getElevationAdjustment
573
564
  */
574
565
  adjustZenith(zenith, elevation) {
575
566
  let adjustedZenith = zenith;
@@ -592,7 +583,22 @@ export class NOAACalculator {
592
583
  */
593
584
  static JULIAN_DAYS_PER_CENTURY = 36525;
594
585
  /**
595
- * @see AstronomicalCalculator#getUTCSunrise(Calendar, GeoLocation, double, boolean)
586
+ * A method that calculates UTC sunrise as well as any time based on an angle above or below sunrise.
587
+ * @param date
588
+ * Used to calculate day of year.
589
+ * @param geoLocation
590
+ * The location information used for astronomical calculating sun times.
591
+ * @param zenith
592
+ * the azimuth below the vertical zenith of 90 degrees. for sunrise typically the {@link adjustZenith
593
+ * zenith} used for the calculation uses geometric zenith of 90&deg; and {@link adjustZenith adjusts}
594
+ * this slightly to account for solar refraction and the sun's radius. Another example would be
595
+ * {@link getBeginNauticalTwilight} that passes
596
+ * {@link NAUTICAL_ZENITH} to this method.
597
+ * @param adjustForElevation
598
+ * Should the time be adjusted for elevation
599
+ * @return The UTC time of sunrise in 24 hour format. 5:45:00 AM will return 5.75.0. If an error was encountered in
600
+ * the calculation (expected behavior for some locations such as near the poles,
601
+ * `NaN` will be returned.
596
602
  */
597
603
  getUTCSunrise(date, geoLocation, zenith, adjustForElevation) {
598
604
  const elevation = adjustForElevation
@@ -611,7 +617,22 @@ export class NOAACalculator {
611
617
  return sunrise;
612
618
  }
613
619
  /**
614
- * @see AstronomicalCalculator#getUTCSunset(Calendar, GeoLocation, double, boolean)
620
+ * A method that calculates UTC sunset as well as any time based on an angle above or below sunset.
621
+ * @param date
622
+ * Used to calculate day of year.
623
+ * @param geoLocation
624
+ * The location information used for astronomical calculating sun times.
625
+ * @param zenith
626
+ * the azimuth below the vertical zenith of 90&deg;. For sunset typically the {@link adjustZenith
627
+ * zenith} used for the calculation uses geometric zenith of 90&deg; and {@link adjustZenith adjusts}
628
+ * this slightly to account for solar refraction and the sun's radius. Another example would be
629
+ * {@link getEndNauticalTwilight} that passes
630
+ * {@link NAUTICAL_ZENITH} to this method.
631
+ * @param adjustForElevation
632
+ * Should the time be adjusted for elevation
633
+ * @return The UTC time of sunset in 24 hour format. 5:45:00 AM will return 5.75.0. If an error was encountered in
634
+ * the calculation (expected behavior for some locations such as near the poles,
635
+ * `NaN` will be returned.
615
636
  */
616
637
  getUTCSunset(date, geoLocation, zenith, adjustForElevation) {
617
638
  const elevation = adjustForElevation
@@ -632,8 +653,8 @@ export class NOAACalculator {
632
653
  /**
633
654
  * A utility method that will allow the calculation of a temporal (solar) hour based on the sunrise and sunset
634
655
  * passed as parameters to this method. An example of the use of this method would be the calculation of a
635
- * non-elevation adjusted temporal hour by passing in {@link #getSeaLevelSunrise() sea level sunrise} and
636
- * {@link #getSeaLevelSunset() sea level sunset} as parameters.
656
+ * non-elevation adjusted temporal hour by passing in {@link getSeaLevelSunrise() sea level sunrise} and
657
+ * {@link getSeaLevelSunset() sea level sunset} as parameters.
637
658
  *
638
659
  * @param {Temporal.ZonedDateTime | null} startOfDay
639
660
  * The start of the day.
@@ -641,13 +662,13 @@ export class NOAACalculator {
641
662
  * The end of the day.
642
663
  *
643
664
  * @return {number} the <code>long</code> millisecond length of the temporal hour. If the calculation can't be computed a
644
- * {@link Long#MIN_VALUE} will be returned. See detailed explanation on top of the page.
665
+ * `NaN` will be returned. See detailed explanation on top of the page.
645
666
  *
646
- * @see #getTemporalHour()
667
+ * @see getTemporalHour()
647
668
  */
648
669
  getTemporalHour(startOfDay = this.getSeaLevelSunrise(), endOfDay = this.getSeaLevelSunset()) {
649
670
  if (startOfDay === null || endOfDay === null) {
650
- return Long_MIN_VALUE;
671
+ return NaN;
651
672
  }
652
673
  const delta = endOfDay.epochMilliseconds - startOfDay.epochMilliseconds;
653
674
  return Math.floor(delta / 12);
@@ -684,7 +705,7 @@ export class NOAACalculator {
684
705
  * @return {Temporal.ZonedDateTime | null} The Date.
685
706
  */
686
707
  getDateFromTime(time, isSunrise) {
687
- if (Number.isNaN(time)) {
708
+ if (isNaN(time)) {
688
709
  return null;
689
710
  }
690
711
  let calculatedTime = time;
@@ -929,8 +950,7 @@ export class NOAACalculator {
929
950
  }
930
951
  /**
931
952
  * Returns the <a href="http://en.wikipedia.org/wiki/Hour_angle">hour angle</a> of the sun at sunset for the
932
- * latitude. TODO: use - {@link #getSunHourAngleAtSunrise(double, double, double)} implementation to avoid
933
- * duplication of code.
953
+ * latitude.
934
954
  * @private
935
955
  * @param {number} lat
936
956
  * the latitude of observer in degrees
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/noaa",
3
- "version": "0.8.8",
3
+ "version": "0.8.10",
4
4
  "description": "sunrise and sunset via NOAA algorithm with elevation, based on KosherJava",
5
5
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
6
6
  "contributors": [
@@ -15,6 +15,7 @@
15
15
  },
16
16
  "main": "dist/index.cjs",
17
17
  "module": "dist/index.js",
18
+ "typings": "dist/index.d.ts",
18
19
  "type": "module",
19
20
  "exports": {
20
21
  "import": "./dist/index.js",
@@ -22,17 +23,14 @@
22
23
  "types": "./dist/index.d.ts"
23
24
  },
24
25
  "scripts": {
25
- "test": "echo \"Error: no test specified\" && exit 1",
26
+ "test": "echo \"Nothing to test -- no test specified\" && exit 0",
26
27
  "build": "npm run build:cjs && mv dist/index.js dist/index.cjs && npm run build:es6",
27
28
  "build:cjs": "tsc -p ./tsconfig-cjs.json",
28
29
  "build:es6": "tsc",
29
- "lint": "gts lint",
30
30
  "clean": "gts clean",
31
- "compile": "tsc",
32
31
  "fix": "gts fix",
33
- "prepare": "npm run compile",
34
- "pretest": "npm run compile",
35
- "posttest": "npm run lint"
32
+ "prepare": "npm run build",
33
+ "pretest": "npm run build"
36
34
  },
37
35
  "keywords": [
38
36
  "zmanim",