Skip to content

Commit

Permalink
Fix event categories for Erev Purim
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Oct 26, 2021
1 parent 3b95d3f commit 8ffe9b5
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 25 deletions.
42 changes: 22 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/rest-api",
"version": "3.8.4",
"version": "3.8.5",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"keywords": [
"hebcal"
Expand Down Expand Up @@ -59,12 +59,12 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.6",
"ava": "^3.15.0",
"core-js": "^3.18.3",
"eslint": "^8.0.1",
"core-js": "^3.19.0",
"eslint": "^8.1.0",
"eslint-config-google": "^0.14.0",
"jsdoc": "^3.6.7",
"jsdoc-to-markdown": "^7.1.0",
"rollup": "^2.58.0",
"rollup": "^2.58.3",
"rollup-plugin-terser": "^7.0.2"
}
}
3 changes: 3 additions & 0 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,15 @@ export function getEventCategories(ev) {
case 'Lag BaOmer':
case 'Leil Selichot':
case 'Pesach Sheni':
case 'Erev Purim':
case 'Purim Katan':
case 'Shushan Purim':
case 'Tu B\'Av':
case 'Tu BiShvat':
case 'Rosh Hashana LaBehemot':
return ['holiday', 'minor'];
case 'Erev Tish\'a B\'Av':
return ['holiday', 'fast', 'major'];
default:
return ['holiday', 'major'];
}
Expand Down
103 changes: 102 additions & 1 deletion src/common.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava';
import {getDownloadFilename, getCalendarTitle, makeTorahMemoText} from './common';
import {getDownloadFilename, getCalendarTitle, makeTorahMemoText, getEventCategories} from './common';
import {HebrewCalendar, Location, Event, HDate, flags} from '@hebcal/core';

test('getDownloadFilename', (t) => {
Expand Down Expand Up @@ -93,3 +93,104 @@ test('makeTorahMemoText-userEvent', (t) => {
const holidayEvent = new Event(hd, 'Holiday Event', 0);
t.is(makeTorahMemoText(holidayEvent, false), 'Haftarah: Isaiah 66:1 - 66:24');
});

test('getEventCategories', (t) => {
const events = HebrewCalendar.calendar({year: 2022});
const actual = events.map((ev) => {
return {
h: ev.getDesc(),
c: getEventCategories(ev),
};
});
const expected = [
{h: 'Rosh Chodesh Sh\'vat', c: ['roshchodesh']},
{h: 'Shabbat Shirah', c: ['holiday', 'shabbat']},
{h: 'Tu BiShvat', c: ['holiday', 'minor']},
{h: 'Rosh Chodesh Adar I', c: ['roshchodesh']},
{h: 'Rosh Chodesh Adar I', c: ['roshchodesh']},
{h: 'Purim Katan', c: ['holiday', 'minor']},
{h: 'Shabbat Shekalim', c: ['holiday', 'shabbat']},
{h: 'Rosh Chodesh Adar II', c: ['roshchodesh']},
{h: 'Rosh Chodesh Adar II', c: ['roshchodesh']},
{h: 'Shabbat Zachor', c: ['holiday', 'shabbat']},
{h: 'Ta\'anit Esther', c: ['holiday', 'fast']},
{h: 'Erev Purim', c: ['holiday', 'minor']},
{h: 'Purim', c: ['holiday', 'minor']},
{h: 'Shushan Purim', c: ['holiday', 'minor']},
{h: 'Shabbat Parah', c: ['holiday', 'shabbat']},
{h: 'Shabbat HaChodesh', c: ['holiday', 'shabbat']},
{h: 'Rosh Chodesh Nisan', c: ['roshchodesh']},
{h: 'Shabbat HaGadol', c: ['holiday', 'shabbat']},
{h: 'Yom HaAliyah', c: ['holiday', 'modern']},
{h: 'Ta\'anit Bechorot', c: ['holiday', 'fast']},
{h: 'Erev Pesach', c: ['holiday', 'major']},
{h: 'Pesach I', c: ['holiday', 'major']},
{h: 'Pesach II', c: ['holiday', 'major']},
{h: 'Pesach III (CH\'\'M)', c: ['holiday', 'major', 'cholhamoed']},
{h: 'Pesach IV (CH\'\'M)', c: ['holiday', 'major', 'cholhamoed']},
{h: 'Pesach V (CH\'\'M)', c: ['holiday', 'major', 'cholhamoed']},
{h: 'Pesach VI (CH\'\'M)', c: ['holiday', 'major', 'cholhamoed']},
{h: 'Pesach VII', c: ['holiday', 'major']},
{h: 'Pesach VIII', c: ['holiday', 'major']},
{h: 'Yom HaShoah', c: ['holiday', 'modern']},
{h: 'Rosh Chodesh Iyyar', c: ['roshchodesh']},
{h: 'Rosh Chodesh Iyyar', c: ['roshchodesh']},
{h: 'Yom HaZikaron', c: ['holiday', 'modern']},
{h: 'Yom HaAtzma\'ut', c: ['holiday', 'modern']},
{h: 'Pesach Sheni', c: ['holiday', 'minor']},
{h: 'Lag BaOmer', c: ['holiday', 'minor']},
{h: 'Yom Yerushalayim', c: ['holiday', 'modern']},
{h: 'Rosh Chodesh Sivan', c: ['roshchodesh']},
{h: 'Erev Shavuot', c: ['holiday', 'major']},
{h: 'Shavuot I', c: ['holiday', 'major']},
{h: 'Shavuot II', c: ['holiday', 'major']},
{h: 'Rosh Chodesh Tamuz', c: ['roshchodesh']},
{h: 'Rosh Chodesh Tamuz', c: ['roshchodesh']},
{h: 'Tzom Tammuz', c: ['holiday', 'fast']},
{h: 'Rosh Chodesh Av', c: ['roshchodesh']},
{h: 'Shabbat Chazon', c: ['holiday', 'shabbat']},
{h: 'Erev Tish\'a B\'Av', c: ['holiday', 'fast', 'major']},
{h: 'Tish\'a B\'Av (observed)', c: ['holiday', 'fast', 'major']},
{h: 'Tu B\'Av', c: ['holiday', 'minor']},
{h: 'Shabbat Nachamu', c: ['holiday', 'shabbat']},
{h: 'Rosh Chodesh Elul', c: ['roshchodesh']},
{h: 'Rosh Hashana LaBehemot', c: ['holiday', 'minor']},
{h: 'Rosh Chodesh Elul', c: ['roshchodesh']},
{h: 'Leil Selichot', c: ['holiday', 'minor']},
{h: 'Erev Rosh Hashana', c: ['holiday', 'major']},
{h: 'Rosh Hashana 5783', c: ['holiday', 'major']},
{h: 'Rosh Hashana II', c: ['holiday', 'major']},
{h: 'Tzom Gedaliah', c: ['holiday', 'fast']},
{h: 'Shabbat Shuva', c: ['holiday', 'shabbat']},
{h: 'Erev Yom Kippur', c: ['holiday', 'major']},
{h: 'Yom Kippur', c: ['holiday', 'major']},
{h: 'Erev Sukkot', c: ['holiday', 'major']},
{h: 'Sukkot I', c: ['holiday', 'major']},
{h: 'Sukkot II', c: ['holiday', 'major']},
{h: 'Sukkot III (CH\'\'M)', c: ['holiday', 'major', 'cholhamoed']},
{h: 'Sukkot IV (CH\'\'M)', c: ['holiday', 'major', 'cholhamoed']},
{h: 'Sukkot V (CH\'\'M)', c: ['holiday', 'major', 'cholhamoed']},
{h: 'Sukkot VI (CH\'\'M)', c: ['holiday', 'major', 'cholhamoed']},
{h: 'Sukkot VII (Hoshana Raba)', c: ['holiday', 'major', 'cholhamoed']},
{h: 'Shmini Atzeret', c: ['holiday', 'major']},
{h: 'Simchat Torah', c: ['holiday', 'major']},
{h: 'Rosh Chodesh Cheshvan', c: ['roshchodesh']},
{h: 'Rosh Chodesh Cheshvan', c: ['roshchodesh']},
{h: 'Yom HaAliyah School Observance', c: ['holiday', 'modern']},
{h: 'Sigd', c: ['holiday', 'modern']},
{h: 'Rosh Chodesh Kislev', c: ['roshchodesh']},
{h: 'Rosh Chodesh Kislev', c: ['roshchodesh']},
{h: 'Chanukah: 1 Candle', c: ['holiday', 'major']},
{h: 'Chanukah: 2 Candles', c: ['holiday', 'major']},
{h: 'Chanukah: 3 Candles', c: ['holiday', 'major']},
{h: 'Chanukah: 4 Candles', c: ['holiday', 'major']},
{h: 'Chanukah: 5 Candles', c: ['holiday', 'major']},
{h: 'Chanukah: 6 Candles', c: ['holiday', 'major']},
{h: 'Chanukah: 7 Candles', c: ['holiday', 'major']},
{h: 'Rosh Chodesh Tevet', c: ['roshchodesh']},
{h: 'Chanukah: 8 Candles', c: ['holiday', 'major']},
{h: 'Rosh Chodesh Tevet', c: ['roshchodesh']},
{h: 'Chanukah: 8th Day', c: ['holiday', 'minor']},
];
t.deepEqual(actual, expected);
});

0 comments on commit 8ffe9b5

Please sign in to comment.