diff --git a/package-lock.json b/package-lock.json index e6628d5..4ea19ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@hebcal/rest-api", - "version": "3.8.5", + "version": "3.8.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@hebcal/rest-api", - "version": "3.8.5", + "version": "3.8.6", "license": "BSD-2-Clause", "dependencies": { - "@hebcal/core": "^3.26.7", + "@hebcal/core": "^3.27.0", "@hebcal/leyning": "^4.10.2" }, "devDependencies": { @@ -1705,9 +1705,9 @@ } }, "node_modules/@hebcal/core": { - "version": "3.26.7", - "resolved": "https://registry.npmjs.org/@hebcal/core/-/core-3.26.7.tgz", - "integrity": "sha512-E47pzDdwdEe2YygZWm71fQFNSfVfNwlL5FzVW/aJztm3VD4vUz+PE0ZBIvCHQTIANvR07OZtL8qV7e2bQuduQw==", + "version": "3.27.0", + "resolved": "https://registry.npmjs.org/@hebcal/core/-/core-3.27.0.tgz", + "integrity": "sha512-NOvgjB27NolhWeWk5/uo5F4Zx8G138VSijWYzmNfv75XBAF5UsSen5JoAvf67rtPS60iixD6K5ELWZ51owBn1Q==", "engines": { "node": ">=10.21.0" } @@ -3467,9 +3467,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.3.883", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.883.tgz", - "integrity": "sha512-goyjNx4wB9j911PBteb+AXNbErug7rJVkmDXWdw5SCVn2JlARBwsqucPkvp1h5mXWxHUbBRK3bwXTrqSxSiAIQ==", + "version": "1.3.884", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.884.tgz", + "integrity": "sha512-kOaCAa+biA98PwH5BpCkeUeTL6mCeg8p3Q3OhqzPyqhu/5QUnWAN2wr/3IK8xMQxIV76kfoQpP+Bn/wij/jXrg==", "dev": true }, "node_modules/emittery": { @@ -9115,9 +9115,9 @@ } }, "@hebcal/core": { - "version": "3.26.7", - "resolved": "https://registry.npmjs.org/@hebcal/core/-/core-3.26.7.tgz", - "integrity": "sha512-E47pzDdwdEe2YygZWm71fQFNSfVfNwlL5FzVW/aJztm3VD4vUz+PE0ZBIvCHQTIANvR07OZtL8qV7e2bQuduQw==" + "version": "3.27.0", + "resolved": "https://registry.npmjs.org/@hebcal/core/-/core-3.27.0.tgz", + "integrity": "sha512-NOvgjB27NolhWeWk5/uo5F4Zx8G138VSijWYzmNfv75XBAF5UsSen5JoAvf67rtPS60iixD6K5ELWZ51owBn1Q==" }, "@hebcal/leyning": { "version": "4.10.2", @@ -10464,9 +10464,9 @@ "dev": true }, "electron-to-chromium": { - "version": "1.3.883", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.883.tgz", - "integrity": "sha512-goyjNx4wB9j911PBteb+AXNbErug7rJVkmDXWdw5SCVn2JlARBwsqucPkvp1h5mXWxHUbBRK3bwXTrqSxSiAIQ==", + "version": "1.3.884", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.884.tgz", + "integrity": "sha512-kOaCAa+biA98PwH5BpCkeUeTL6mCeg8p3Q3OhqzPyqhu/5QUnWAN2wr/3IK8xMQxIV76kfoQpP+Bn/wij/jXrg==", "dev": true }, "emittery": { diff --git a/package.json b/package.json index 4aad96d..f5e752f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hebcal/rest-api", - "version": "3.8.5", + "version": "3.8.6", "author": "Michael J. Radwin (https://github.com/mjradwin)", "keywords": [ "hebcal" @@ -21,7 +21,7 @@ "url": "https://github.com/hebcal/hebcal-rest-api/issues" }, "dependencies": { - "@hebcal/core": "^3.26.7", + "@hebcal/core": "^3.27.0", "@hebcal/leyning": "^4.10.2" }, "scripts": { diff --git a/rest-api.d.ts b/rest-api.d.ts index 7fd8758..e9444ca 100644 --- a/rest-api.d.ts +++ b/rest-api.d.ts @@ -30,6 +30,10 @@ declare module '@hebcal/rest-api' { * Appends utm_source and utm_medium parameters to a URL */ export function appendIsraelAndTracking(url: string, il: boolean, utmSource: string, utmMedium: string, utmCampaign?: string): string; + /** + * @private + */ + export function shouldRenderBrief(ev: Event): boolean; /** * @param [lang] - language such as 'he' (default 'en-US') * @param [evPubDate] - if true, use event time as pubDate (false uses lastBuildDate) diff --git a/src/classic-rest-api.js b/src/classic-rest-api.js index 1cb5fb5..7f31c50 100644 --- a/src/classic-rest-api.js +++ b/src/classic-rest-api.js @@ -5,6 +5,7 @@ import { getEventCategories, toISOString, appendIsraelAndTracking, + shouldRenderBrief, } from './common'; import countryNames from './countryNames.json'; import holidayDescription from './holidays.json'; @@ -44,8 +45,6 @@ export function eventsToClassicApi(events, options, leyning=true) { return result; } -const BRIEF_FLAGS = flags.DAF_YOMI | flags.HEBREW_DATE; - /** * Converts a Hebcal event to a classic Hebcal.com JSON API object * @param {Event} ev @@ -63,7 +62,7 @@ export function eventToClassicApiObject(ev, options, leyning=true) { toISOString(dt); const categories = getEventCategories(ev); const mask = ev.getFlags(); - let title = timed || (mask & BRIEF_FLAGS) ? ev.renderBrief(options.locale) : ev.render(options.locale); + let title = shouldRenderBrief(ev) ? ev.renderBrief(options.locale) : ev.render(options.locale); const desc = ev.getDesc(); const candles = desc === 'Havdalah' || desc === 'Candle lighting'; if (candles) { diff --git a/src/common.js b/src/common.js index c1c46cc..bc01c80 100644 --- a/src/common.js +++ b/src/common.js @@ -276,3 +276,21 @@ export function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampai const campaign = utmCampaign ? `&utm_campaign=${utmCampaign}` : ''; return url + sep + utm + campaign; } + +/** + * @private + * @param {Event} ev + * @return {boolean} + */ +export function shouldRenderBrief(ev) { + if (typeof ev.eventTime !== 'undefined') return true; + const mask = ev.getFlags(); + if (mask & flags.HEBREW_DATE) { + const hd = ev.getDate(); + return (hd.getDate() === 1) ? false : true; + } else if (mask & flags.DAF_YOMI) { + return true; + } else { + return false; + } +} diff --git a/src/fullcalendar.js b/src/fullcalendar.js index bfa0c4f..68b7afe 100644 --- a/src/fullcalendar.js +++ b/src/fullcalendar.js @@ -1,10 +1,8 @@ import {Locale, flags, Zmanim} from '@hebcal/core'; import {getEventCategories, makeTorahMemoText, toISOString, - appendIsraelAndTracking} from './common'; + appendIsraelAndTracking, shouldRenderBrief} from './common'; import holidayDescription from './holidays.json'; -const BRIEF_FLAGS = flags.DAF_YOMI | flags.HEBREW_DATE; - /** * Converts a Hebcal event to a FullCalendar.io object * @param {Event} ev @@ -19,7 +17,7 @@ export function eventToFullCalendar(ev, tzid, il) { classes.push('yomtov'); } const timed = Boolean(ev.eventTime); - const title = timed || (mask & BRIEF_FLAGS) ? ev.renderBrief() : ev.render(); + const title = shouldRenderBrief(ev) ? ev.renderBrief() : ev.render(); const start = timed ? Zmanim.formatISOWithTimeZone(tzid, ev.eventTime) : toISOString(ev.getDate().greg());