Skip to content

Commit

Permalink
Fix translations for Yom Kippur Katan
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Dec 23, 2024
1 parent 41717d8 commit 92ba354
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 40 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/core",
"version": "5.8.7",
"version": "5.8.8",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"contributors": [
"Eyal Schachter (https://github.com/Scimonster)",
Expand Down
8 changes: 0 additions & 8 deletions size-demo/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import prettyBytes from 'pretty-bytes';
import {defineConfig, OutputChunk, Plugin, RollupOptions} from 'rollup';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import bundleSize from 'rollup-plugin-bundle-size';
import json from '@rollup/plugin-json';
import terser from '@rollup/plugin-terser';
Expand All @@ -11,13 +10,6 @@ import {appendFileSync, readdirSync, writeFileSync} from 'fs';
import {basename} from 'path';
import {visualizer} from 'rollup-plugin-visualizer';

const TARGETS_BROWSER = {
chrome: '103',
firefox: '91',
edge: '84',
safari: '15.6',
};

const sizeFile = './size-demo/sizes.md';
writeFileSync(sizeFile, '# Bundle sizes\n\n');

Expand Down
8 changes: 2 additions & 6 deletions src/HolidayEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,8 @@ export class HolidayEvent extends Event {
*/
clone(): HolidayEvent {
const ev = new HolidayEvent(this.date, this.desc, this.mask);
for (const property in this) {
// eslint-disable-next-line no-prototype-builtins
if (this.hasOwnProperty(property)) {
Object.defineProperty(ev, property, {value: this[property]});
}
}
// overwrite all enumerable properties
Object.assign(ev, this);
return ev;
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,11 @@ function appendHolidayAndRelated(
const isMajorFast = Boolean(eFlags & MAJOR_FAST);
const isMinorFast = Boolean(eFlags & MINOR_FAST);
let fastEv;
if (options.candlelighting && (isMajorFast || isMinorFast)) {
if (
options.candlelighting &&
(isMajorFast || isMinorFast) &&
ev.getDesc() !== 'Yom Kippur'
) {
ev = fastEv = makeFastStartEnd(ev, options);
if (
fastEv.startEvent &&
Expand Down
38 changes: 22 additions & 16 deletions src/candles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable max-len */
import {HDate, months, isoDateString} from '@hebcal/hdate';
import {HDate, months} from '@hebcal/hdate';
import {CalOptions} from './CalOptions';
import {Location} from './location';
import {Event, flags} from './event';
Expand Down Expand Up @@ -72,33 +72,39 @@ const FAST_ENDS = 'Fast ends';

/** A fast day also contains a start and end time */
export class FastDayEvent extends HolidayEvent {
/** original event */
readonly linkedEvent: HolidayEvent;
/** this will be a "Fast begins" event */
readonly startEvent?: TimedEvent;
/** this will be a "Fast ends" event */
readonly endEvent?: TimedEvent;
constructor(
date: HDate,
desc: string,
mask: number,
linkedEvent: HolidayEvent,
startEvent?: TimedEvent,
endEvent?: TimedEvent
) {
super(date, desc, mask);
super(linkedEvent.getDate(), linkedEvent.getDesc(), linkedEvent.getFlags());
this.linkedEvent = linkedEvent;
this.startEvent = startEvent;
this.endEvent = endEvent;
}
render(locale?: string): string {
return this.linkedEvent.render(locale);
}
renderBrief(locale?: string): string {
return this.linkedEvent.renderBrief(locale);
}
urlDateSuffix(): string {
if (this.getDesc() === "Asara B'Tevet") {
const isoDate = isoDateString(this.getDate().greg());
return isoDate.replace(/-/g, '');
}
return super.urlDateSuffix();
return this.linkedEvent.urlDateSuffix();
}
url(): string | undefined {
if (this.getFlags() & flags.YOM_KIPPUR_KATAN) {
return undefined;
}
return super.url();
return this.linkedEvent.url();
}
getEmoji(): string {
return this.linkedEvent.getEmoji();
}
getCategories(): string[] {
return this.linkedEvent.getCategories();
}
}

Expand All @@ -112,7 +118,7 @@ export function makeFastStartEnd(
): FastDayEvent {
const desc = ev.getDesc();
if (desc === 'Yom Kippur') {
return ev;
throw new RangeError('YK does not require this function');
}
const hd = ev.getDate();
const dt = hd.greg();
Expand Down Expand Up @@ -147,7 +153,7 @@ export function makeFastStartEnd(
}
}
}
const ev2 = new FastDayEvent(hd, desc, ev.getFlags(), startEvent, endEvent);
const ev2 = new FastDayEvent(ev, startEvent, endEvent);
// copy properties such as memo or emoji
Object.assign(ev2, ev);
return ev2;
Expand Down
8 changes: 2 additions & 6 deletions src/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,8 @@ export class Event {
*/
clone(): Event {
const ev = new Event(this.date, this.desc, this.mask);
for (const property in this) {
// eslint-disable-next-line no-prototype-builtins
if (this.hasOwnProperty(property)) {
Object.defineProperty(ev, property, {value: this[property]});
}
}
// overwrite all enumerable properties
Object.assign(ev, this);
return ev;
}
/**
Expand Down
4 changes: 4 additions & 0 deletions test/hebcal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,8 @@ test('ykk-only', () => {
expect(ev).toBeInstanceOf(YomKippurKatanEvent);
expect(ev.url()).toBeUndefined();
expect(ev.memo).toBe('Minor Day of Atonement on the day preceeding Rosh Chodesh Kislev');
expect(ev.render('en')).toBe('Yom Kippur Katan Kislev');
expect(ev.render('he')).toBe('יוֹם כִּפּוּר קָטָן כִּסְלֵו');
});

test('ykk with location copies attributes from src', () => {
Expand All @@ -614,6 +616,8 @@ test('ykk with location copies attributes from src', () => {
expect(ev).toBeInstanceOf(FastDayEvent);
expect(ev.url()).toBeUndefined();
expect(ev.memo).toBe('Minor Day of Atonement on the day preceeding Rosh Chodesh Adar');
expect(ev.render('en')).toBe('Yom Kippur Katan Adar');
expect(ev.render('he')).toBe('יוֹם כִּפּוּר קָטָן אַדָר');
});

test('hallel', () => {
Expand Down

0 comments on commit 92ba354

Please # to comment.