Skip to content

Commit

Permalink
Don't generate Candle-lighting events for Chanukah when options.noHol…
Browse files Browse the repository at this point in the history
…idays present
  • Loading branch information
mjradwin committed Dec 10, 2020
1 parent 734b83a commit 05c1981
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 14 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/core",
"version": "2.7.0",
"version": "2.8.0",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"contributors": [
"Eyal Schachter (https://github.com/Scimonster)",
Expand Down Expand Up @@ -65,23 +65,23 @@
},
"devDependencies": {
"@ava/babel": "^1.0.1",
"@babel/core": "^7.12.8",
"@babel/preset-env": "^7.12.7",
"@babel/register": "^7.12.1",
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.10",
"@babel/register": "^7.12.10",
"@hebcal/solar-calc": "^1.0.4",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-babel": "^5.2.2",
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"ava": "^3.13.0",
"core-js": "^3.7.0",
"eslint": "^7.14.0",
"ava": "^3.14.0",
"core-js": "^3.8.1",
"eslint": "^7.15.0",
"eslint-config-google": "^0.14.0",
"gematriya": "^2.0.0",
"jsdoc": "^3.6.6",
"jsdoc-to-markdown": "^6.0.1",
"nyc": "^15.1.0",
"rollup": "^2.33.3",
"rollup": "^2.34.2",
"rollup-plugin-terser": "^7.0.2",
"tsd-jsdoc": "^2.5.0",
"ttag-cli": "^1.8.8"
Expand Down
31 changes: 29 additions & 2 deletions src/candles.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ const days = {
SAT: 6,
};

/**
* @private
* This method returns the tzais (nightfall) based on the opinion of the
* Geonim calculated as 30 minutes after sunset during the equinox
* (on March 16, about 4 days before the astronomical equinox, the day that
* a solar hour is 60 minutes) in Yerushalayim.
* @see {https://kosherjava.com/zmanim/docs/api/com/kosherjava/zmanim/ComplexZmanimCalendar.html#getTzaisGeonim7Point083Degrees()}
*/
const TZEIT_3MEDIUM_STARS = 7.083;

/**
* @private
* @param {Intl.DateTimeFormat} timeFormat
Expand Down Expand Up @@ -212,15 +222,15 @@ export function makeFastStartEnd(ev, hd, location, timeFormat) {
const begin = makeTimedEvent(hd, sunset, 'Fast begins', ev, timeFormat);
return [begin, null];
} else if (desc === 'Tish\'a B\'Av') {
const end = makeTimedEvent(hd, zmanim.tzeit(7.083), 'Fast ends', ev, timeFormat);
const end = makeTimedEvent(hd, zmanim.tzeit(TZEIT_3MEDIUM_STARS), 'Fast ends', ev, timeFormat);
return [null, end];
}
const dawn = zmanim.alotHaShachar();
const begin = makeTimedEvent(hd, dawn, 'Fast begins', ev, timeFormat);
if (dt.getDay() === 5 || (hd.getDate() === 14 && hd.getMonth() === months.NISAN)) {
return [begin, null];
}
const end = makeTimedEvent(hd, zmanim.tzeit(7.083), 'Fast ends', ev, timeFormat);
const end = makeTimedEvent(hd, zmanim.tzeit(TZEIT_3MEDIUM_STARS), 'Fast ends', ev, timeFormat);
return [begin, end];
}

Expand All @@ -239,3 +249,20 @@ function makeTimedEvent(hd, time, desc, ev, timeFormat) {
}
return new TimedEvent(hd, desc, ev.getFlags(), time, formatTime(timeFormat, time), ev);
}


/**
* Makes a candle-lighting event for Chankah (not on Friday/Saturday)
* @private
* @param {Event} ev
* @param {HDate} hd
* @param {Location} location
* @param {Intl.DateTimeFormat} timeFormat
* @return {TimedEvent}
*/
export function makeWeekdayChanukahCandleLighting(ev, hd, location, timeFormat) {
const zmanim = new Zmanim(hd.greg(), location.getLatitude(), location.getLongitude());
const candleLightingTime = zmanim.tzeit(TZEIT_3MEDIUM_STARS);
// const candleLightingTime = zmanim.sunset();
return makeTimedEvent(hd, candleLightingTime, ev.getDesc(), ev, timeFormat);
}
23 changes: 21 additions & 2 deletions src/candles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ test('candles-only-diaspora', (t) => {
candlelighting: true,
};
const events = HebrewCalendar.calendar(options);
t.is(events.length, 126);
t.is(events.length, 120);
t.is(events[0].getFlags(), flags.LIGHT_CANDLES);
t.is(events[0].render(), 'Candle lighting: 16:10');
t.is(events[0].getDesc(), 'Candle lighting');
Expand Down Expand Up @@ -208,7 +208,7 @@ test('candles-only-israel', (t) => {
candlelighting: true,
};
const events = HebrewCalendar.calendar(options);
t.is(events.length, 123);
t.is(events.length, 117);
t.is(events[0].getFlags(), flags.LIGHT_CANDLES, 'Candle lighting 0');
t.is(events[33].getFlags(), flags.CHAG | flags.YOM_TOV_ENDS | flags.IL_ONLY, 'Havdalah in Israel on Pesach VII');
});
Expand Down Expand Up @@ -338,3 +338,22 @@ test('fastStartEnd-9av', (t) => {
];
t.deepEqual(events.map(eventTitleDateTime), expected);
});

test('no-chanukah-candles-when-noHolidays', (t) => {
const options = {
candlelighting: true,
noHolidays: true,
start: new Date(2020, 11, 9),
end: new Date(2020, 11, 19),
location: Location.lookup('Seattle'),
};
const events = HebrewCalendar.calendar(options);
const expected = [
{date: '2020-12-11', time: '15:59', desc: 'Candle lighting'},
{date: '2020-12-12', time: '17:10', desc: 'Havdalah'},
{date: '2020-12-18', time: '16:01', desc: 'Candle lighting'},
{date: '2020-12-19', time: '17:12', desc: 'Havdalah'},
];
const actual = events.map(eventTitleDateTime);
t.deepEqual(actual, expected);
});
2 changes: 1 addition & 1 deletion src/hebcal.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function getMaskFromOptions(options) {
LIGHT_CANDLES | LIGHT_CANDLES_TZEIS | CHANUKAH_CANDLES;
}
if (options.candlelighting) {
mask |= LIGHT_CANDLES | LIGHT_CANDLES_TZEIS | CHANUKAH_CANDLES;
mask |= LIGHT_CANDLES | LIGHT_CANDLES_TZEIS;
}
// suppression of defaults
if (options.noRoshChodesh) {
Expand Down

0 comments on commit 05c1981

Please sign in to comment.