Skip to content

Commit

Permalink
Disable candle-lighting for Gregorian years < 100
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed May 24, 2021
1 parent 3c8623b commit 77f1d7d
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/core",
"version": "3.17.3",
"version": "3.17.4",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"contributors": [
"Eyal Schachter (https://github.com/Scimonster)",
Expand Down Expand Up @@ -86,7 +86,7 @@
"jsdoc": "^3.6.7",
"jsdoc-to-markdown": "^7.0.0",
"nyc": "^15.1.0",
"rollup": "^2.48.0",
"rollup": "^2.49.0",
"rollup-plugin-terser": "^7.0.2",
"tsd-jsdoc": "^2.5.0",
"ttag-cli": "^1.9.2"
Expand Down
30 changes: 30 additions & 0 deletions src/candles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,33 @@ test('havdalahDeg', (t) => {
];
t.deepEqual(results, expected);
});

test('candles-year101', (t) => {
const options = {
year: 101,
noHolidays: true,
location: Location.lookup('Boston'),
candlelighting: true,
};
const events = HebrewCalendar.calendar(options);
const actual = events.slice(0, 4).map(eventTitleDateTime);
const expected = [
{date: '0101-01-01', time: '17:16', desc: 'Havdalah'},
{date: '0101-01-07', time: '16:16', desc: 'Candle lighting'},
{date: '0101-01-08', time: '17:22', desc: 'Havdalah'},
{date: '0101-01-14', time: '16:24', desc: 'Candle lighting'},
];
t.deepEqual(actual, expected);
});

test('candles-year99-empty', (t) => {
const options = {
year: 99,
noHolidays: true,
location: Location.lookup('Boston'),
candlelighting: true,
};
const events = HebrewCalendar.calendar(options);
const expected = [];
t.deepEqual(events, expected);
});
4 changes: 4 additions & 0 deletions src/hebcal.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ export const HebrewCalendar = {
warnUnrecognizedOptions(options);
const startAbs = startAndEnd[0];
const endAbs = startAndEnd[1];
const startGreg = g.abs2greg(startAbs);
if (startGreg.getFullYear() < 100) {
options.candlelighting = false;
}
for (let abs = startAbs; abs <= endAbs; abs++) {
const hd = new HDate(abs);
const hyear = hd.getFullYear();
Expand Down
8 changes: 8 additions & 0 deletions src/hebcal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,14 @@ test('molad', (t) => {
test('year2', (t) => {
const events = HebrewCalendar.calendar({year: 2});
t.is(events.length, 80);
const events2 = events.slice(0, 3);
const actual = events2.map(eventISODateDesc);
const expected = [
{date: '0002-01-01', desc: 'Rosh Chodesh Sh\'vat'},
{date: '0002-01-12', desc: 'Shabbat Shirah'},
{date: '0002-01-15', desc: 'Tu BiShvat'},
];
t.deepEqual(actual, expected);
});

test('year0', (t) => {
Expand Down

0 comments on commit 77f1d7d

Please sign in to comment.