diff --git a/package.json b/package.json index 06da57c..08462b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hebcal/icalendar", - "version": "2.7.0", + "version": "2.8.0", "author": "Michael J. Radwin (https://github.com/mjradwin)", "keywords": [ "ical", @@ -23,8 +23,8 @@ "url": "https://github.com/hebcal/hebcal-icalendar/issues" }, "dependencies": { - "@hebcal/core": "^2.6.1", - "@hebcal/rest-api": "^2.7.2", + "@hebcal/core": "^2.7.0", + "@hebcal/rest-api": "^2.8.0", "md5": "^2.3.0" }, "scripts": { @@ -55,19 +55,19 @@ }, "devDependencies": { "@ava/babel": "^1.0.1", - "@babel/core": "^7.12.3", + "@babel/core": "^7.12.8", "@babel/polyfill": "^7.12.1", - "@babel/preset-env": "^7.12.1", + "@babel/preset-env": "^7.12.7", "@babel/register": "^7.12.1", "@rollup/plugin-babel": "^5.2.1", - "@rollup/plugin-commonjs": "^15.1.0", + "@rollup/plugin-commonjs": "^16.0.0", "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-node-resolve": "^9.0.0", + "@rollup/plugin-node-resolve": "^10.0.0", "ava": "^3.13.0", - "eslint": "^7.12.0", + "eslint": "^7.14.0", "eslint-config-google": "^0.14.0", "jsdoc": "^3.6.6", "jsdoc-to-markdown": "^6.0.1", - "rollup": "^2.32.1" + "rollup": "^2.33.3" } } diff --git a/src/icalendar.js b/src/icalendar.js index f84c6ab..fe28c1d 100644 --- a/src/icalendar.js +++ b/src/icalendar.js @@ -1,7 +1,8 @@ /* eslint-disable max-len */ import {flags, Locale} from '@hebcal/core'; import md5 from 'md5'; -import {pad2, getCalendarTitle, makeAnchor, getHolidayDescription, makeTorahMemoText} from '@hebcal/rest-api'; +import {pad2, getCalendarTitle, renderTitleWithoutTime, makeAnchor, + getHolidayDescription, makeTorahMemoText} from '@hebcal/rest-api'; import fs from 'fs'; import {Readable} from 'stream'; import {version} from '../package.json'; @@ -87,10 +88,10 @@ function appendTrackingToUrl(url, il) { */ export function eventToIcal(e, options) { const dtstamp = options.dtstamp || makeDtstamp(new Date()); - let subj = e.render(); + const timed = Boolean(e.eventTime); + let subj = timed ? renderTitleWithoutTime(e) : e.render(); const desc = e.getDesc(); // original untranslated const mask = e.getFlags(); - const timed = Boolean(e.eventTime); const candles = (desc === 'Havdalah' || desc === 'Candle lighting'); let location; if (timed && options.location.name) { @@ -119,13 +120,6 @@ export function eventToIcal(e, options) { startDate += 'T' + pad2(hour) + pad2(minute) + '00'; endDate = startDate; dtargs = `;TZID=${options.location.tzid}`; - // replace "Candle lighting: 15:34" with shorter title - if (candles) { - const colon = subj.indexOf(': '); - if (colon != -1) { - subj = subj.substring(0, colon); - } - } } else { endDate = formatYYYYMMDD(e.getDate().next().greg()); // for all-day untimed, use DTEND;VALUE=DATE intsead of DURATION:P1D. diff --git a/src/icalendar.spec.js b/src/icalendar.spec.js index ffb02b4..c35c1ab 100644 --- a/src/icalendar.spec.js +++ b/src/icalendar.spec.js @@ -356,3 +356,21 @@ test('relcalid', async (t) => { ]; t.deepEqual(lines, expected); }); + +test('fastStartEnd', (t) => { + const options = { + start: new Date(2021, 5, 27), + end: new Date(2021, 5, 27), + location: Location.lookup('Providence'), + candlelighting: true, + }; + const events = HebrewCalendar.calendar(options); + const icals = events.map((ev) => icalendar.eventToIcal(ev, options)); + const summary = icals.map((i) => i.split('\r\n').find((s) => s.startsWith('SUMMARY'))); + const expected = [ + 'SUMMARY:Fast begins', + 'SUMMARY:Tzom Tammuz', + 'SUMMARY:Fast ends', + ]; + t.deepEqual(summary, expected); +});