Skip to content

Commit

Permalink
Add Zmanim setUseElevation and getUseElevation
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed May 8, 2024
1 parent 1407a6e commit 795a280
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 1 deletion.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,8 @@ https://gml.noaa.gov/grad/solcalc/calcdetails.html
* [Zmanim](#Zmanim)
* [new Zmanim(gloc, date, useElevation)](#new_Zmanim_new)
* _instance_
* [.getUseElevation()](#Zmanim+getUseElevation) ⇒ <code>boolean</code>
* [.setUseElevation(useElevation)](#Zmanim+setUseElevation)
* [.timeAtAngle(angle, rising)](#Zmanim+timeAtAngle) ⇒ <code>Date</code>
* [.sunrise()](#Zmanim+sunrise) ⇒ <code>Date</code>
* [.seaLevelSunrise()](#Zmanim+seaLevelSunrise) ⇒ <code>Date</code>
Expand Down Expand Up @@ -1973,6 +1975,24 @@ const zmanim = new Zmanim(gloc, friday, false);
const candleLighting = zmanim.sunsetOffset(-18, true);
const timeStr = Zmanim.formatISOWithTimeZone(tzid, candleLighting);
```
<a name="Zmanim+getUseElevation"></a>

### zmanim.getUseElevation() ⇒ <code>boolean</code>
Returns `true` if elevation adjustment is enabled
for zmanim support elevation adjustment

**Kind**: instance method of [<code>Zmanim</code>](#Zmanim)
<a name="Zmanim+setUseElevation"></a>

### zmanim.setUseElevation(useElevation)
Enables or disables elevation adjustment for zmanim support elevation adjustment

**Kind**: instance method of [<code>Zmanim</code>](#Zmanim)

| Param | Type |
| --- | --- |
| useElevation | <code>boolean</code> |

<a name="Zmanim+timeAtAngle"></a>

### zmanim.timeAtAngle(angle, rising) ⇒ <code>Date</code>
Expand Down
9 changes: 9 additions & 0 deletions hebcal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,15 @@ declare module '@hebcal/core' {
* These zmanim intentionally do not support elevation adjustment.
*/
constructor(gloc: GeoLocation, date: Date | HDate, useElevation?: boolean);
/**
* Returns `true` if elevation adjustment is enabled
* for zmanim support elevation adjustment
*/
getUseElevation(): boolean;
/**
* Enables or disables elevation adjustment for zmanim support elevation adjustment
*/
setUseElevation(useElevation: boolean): void;

/**
* Returns a string like "2022-04-01T13:06:00-11:00"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/core",
"version": "5.3.7",
"version": "5.3.8",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"contributors": [
"Eyal Schachter (https://github.com/Scimonster)",
Expand Down
15 changes: 15 additions & 0 deletions src/zmanim.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ export class Zmanim {
this.noaa = new NOAACalculator(gloc, plainDate);
this.useElevation = Boolean(useElevation);
}
/**
* Returns `true` if elevation adjustment is enabled
* for zmanim support elevation adjustment
* @return {boolean}
*/
getUseElevation() {
return this.useElevation;
}
/**
* Enables or disables elevation adjustment for zmanim support elevation adjustment
* @param {boolean} useElevation
*/
setUseElevation(useElevation) {
this.useElevation = useElevation;
}
/**
* Convenience function to get the time when sun is above or below the horizon
* for a certain angle (in degrees).
Expand Down
16 changes: 16 additions & 0 deletions src/zmanim.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,3 +550,19 @@ test('zmanim-Beitar Ilit', (t) => {
}
t.deepEqual(actual, expected);
});

test('useElevation', (t) => {
const zman = makeZmanWithElevation(); // with useElevation=true
t.is(zman.getUseElevation(), true);
zman.setUseElevation(false);
t.is(zman.getUseElevation(), false);
zman.setUseElevation(true);
t.is(zman.getUseElevation(), true);

const zman2 = makeZman(); // with useElevation=false
t.is(zman2.getUseElevation(), false);
zman2.setUseElevation(true);
t.is(zman2.getUseElevation(), true);
zman2.setUseElevation(false);
t.is(zman2.getUseElevation(), false);
});

0 comments on commit 795a280

Please sign in to comment.