Skip to content

Commit

Permalink
Add heDateParts to eventToClassicApiObject for HebrewDateEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Aug 11, 2022
1 parent c9588e5 commit 47cd5c7
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 31 deletions.
50 changes: 25 additions & 25 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.19.3",
"version": "3.19.4",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"keywords": [
"hebcal"
Expand All @@ -21,8 +21,8 @@
"url": "https://github.com/hebcal/hebcal-rest-api/issues"
},
"dependencies": {
"@hebcal/core": "^3.42.0",
"@hebcal/leyning": "^4.15.1"
"@hebcal/core": "^3.42.1",
"@hebcal/leyning": "^4.17.0"
},
"scripts": {
"build": "rollup -c",
Expand Down Expand Up @@ -56,7 +56,7 @@
"eslint-config-google": "^0.14.0",
"jsdoc": "^3.6.11",
"jsdoc-to-markdown": "^7.1.1",
"rollup": "^2.77.2",
"rollup": "^2.77.3",
"rollup-plugin-terser": "^7.0.2"
}
}
14 changes: 12 additions & 2 deletions src/classic-rest-api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Locale, flags, HebrewCalendar, Zmanim} from '@hebcal/core';
import {Locale, flags, HebrewCalendar, Zmanim, gematriya} from '@hebcal/core';
import * as leyn from '@hebcal/leyning';
import {
getCalendarTitle,
Expand Down Expand Up @@ -97,7 +97,7 @@ export function eventToClassicApiObject(ev, options, leyning=true) {
if (reading) {
result.leyning = formatLeyningResult(reading);
const hyear = hd.getFullYear();
if (isParsha && !il && hyear >= 5745 && hyear <= 5830) {
if (isParsha && !il && hyear >= 5745) {
const triReading = leyn.getTriennialForParshaHaShavua(ev);
if (triReading) {
result.leyning.triennial = formatAliyot({}, triReading);
Expand Down Expand Up @@ -127,6 +127,16 @@ export function eventToClassicApiObject(ev, options, leyning=true) {
},
};
}
if (mask & flags.HEBREW_DATE) {
const yy = hd.getFullYear();
const mm = hd.getMonthName();
const dd = hd.getDate();
result.heDateParts = {
y: gematriya(yy),
m: Locale.gettext(mm, 'he-x-NoNikud'),
d: gematriya(dd),
};
}
const memo = ev.memo || holidayDescription[ev.basename()];
if (memo) {
result.memo = memo;
Expand Down
10 changes: 10 additions & 0 deletions src/classic-rest-api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,11 @@ test('hebdate', (t) => {
category: 'hebdate',
title_orig: '24 Kislev 5756',
hebrew: 'כ״ד כסלו',
heDateParts: {
d: 'כ״ד',
m: 'כסלו',
y: 'תשנ״ו',
},
};
t.deepEqual(obj, expected);
});
Expand Down Expand Up @@ -484,6 +489,11 @@ test('location-zip', (t) => {
category: 'hebdate',
title_orig: '1 Adar II 5782',
hebrew: 'א׳ אדר ב׳',
heDateParts: {
d: 'א׳',
m: 'אדר ב׳',
y: 'תשפ״ב',
},
},
],
};
Expand Down

0 comments on commit 47cd5c7

Please sign in to comment.