Skip to content

Commit

Permalink
Include YK Mincha Torah Reading in CSV
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Sep 20, 2022
1 parent 49ed22b commit a0f20ab
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 28 deletions.
21 changes: 21 additions & 0 deletions bin/triennial-csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env node

const fs = require('fs');
const {HDate} = require('@hebcal/core');
const {writeTriennialCsv} = require('../dist/index');

const today = new HDate();
const hyear = today.getFullYear();

const numTriennialCycles = 5;
const yearNum = ((hyear - 5756) % 3) + 1;

for (let i = 0; i < numTriennialCycles; i++) {
const yearOffset = (i - 1) * 3;
const cycleStartYear = hyear - (yearNum - 1) + yearOffset;
const filename = `triennial-${cycleStartYear}-${cycleStartYear+2}.csv`;
console.log(`Creating ${filename}`);
const stream = fs.createWriteStream(filename, {flags: 'w'});
writeTriennialCsv(stream, cycleStartYear);
stream.end();
}
46 changes: 23 additions & 23 deletions package-lock.json

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

12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/triennial",
"version": "1.0.1",
"version": "1.0.2",
"description": "Javascript Triennial Torah Readings",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand All @@ -22,14 +22,18 @@
},
"homepage": "https://github.com/hebcal/hebcal-triennial#readme",
"dependencies": {
"@hebcal/core": "^3.43.0",
"@hebcal/leyning": "^6.0.3"
"@hebcal/core": "^3.44.2",
"@hebcal/leyning": "^6.0.4"
},
"typings": "types.d.ts",
"files": [
"dist",
"bin",
"types.d.ts"
],
"bin": {
"triennial-csv": "bin/triennial-csv"
},
"ava": {
"files": [
"src/**/*.spec.js"
Expand All @@ -49,7 +53,7 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^14.1.0",
"ava": "^4.3.3",
"core-js": "^3.25.1",
"core-js": "^3.25.2",
"eslint": "^8.23.1",
"eslint-config-google": "^0.14.0",
"jsdoc": "^3.6.11",
Expand Down
11 changes: 10 additions & 1 deletion src/csv.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {HebrewCalendar, flags} from '@hebcal/core';
import {HebrewCalendar, flags, Event} from '@hebcal/core';
import {getLeyningForParshaHaShavua, getLeyningForHoliday,
getLeyningForHolidayKey,
getLeyningKeyForEvent, writeCsvLines} from '@hebcal/leyning';
import {getTriennialForParshaHaShavua, getTriennialHaftaraForHoliday, Triennial} from './triennial';

Expand Down Expand Up @@ -75,6 +76,14 @@ function writeTriennialEventHoliday(stream, ev) {
}
writeCsvLines(stream, ev, reading, il, false);
}
if (!(ev.getFlags() & flags.ROSH_CHODESH)) {
const minchaDesc = ev.getDesc() + ' (Mincha)';
const readingMincha = getLeyningForHolidayKey(minchaDesc);
if (readingMincha) {
const minchaEv = new Event(ev.getDate(), minchaDesc, flags.USER_EVENT);
writeCsvLines(stream, minchaEv, readingMincha, il, false);
}
}
}

/**
Expand Down

0 comments on commit a0f20ab

Please sign in to comment.