Skip to content

Commit

Permalink
Merge pull request #22 from hebcal/2.2.1
Browse files Browse the repository at this point in the history
2.2.1
  • Loading branch information
Scimonster committed Apr 17, 2016
2 parents 7bf7bbf + 75c9dd2 commit d527dcd
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 24 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
version 2.2.1 (2016-04-17 [9 Nisan 5776])
Copy lat and long properties when using HDate().next() and prev()
Make Hebcal().findParsha() not care about spelling format
Fix HDate().getTishreiMonth() returning 0 in Elul
HDate().setMonth() will wrap the year
Tell Node not to keep the process open while listening for events

version 2.2.0 (2014-06-29 [1 Tamuz 5774])
Add Event().routine() method
Default HDate().holidays() to not return routine events
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,23 @@ $ npm install hebcal

...and include Hebcal with `var Hebcal = require('hebcal');`

Hebcal JS is currently at version 2.1.2. It is approximately equivalent to Hebcal C 3.15.
Hebcal JS is currently at version 2.2.1. It is approximately equivalent to Hebcal C 3.15.
I (Eyal) did not write Hebcal JS 1.0. 2.x is a nearly-complete rewrite of it.

The version documented here is 2.2.0.
The version documented here is 2.2.1.

## Releases

* 2.0.0 - 2014-02-18 (19 Adar 1 5774)
* 2.1.0 - 2014-03-16 (14 Adar 2 5774 [Purim])
* 2.1.1 - 2014-04-04 (5 Nisan 5774)
* 2.1.2 - 2014-04-04 (5 Nisan 5774)
* 2.2.0 (current) - 2014-06-29 (1 Tamuz 5774)
* 2.2.0 - 2014-06-29 (1 Tamuz 5774)
* 2.2.1 - 2016-04-17 (9 Nisan 5776)

## Contributors

Hebcal JS was ported from C by Eyal Schachter.
Hebcal JS was ported from C by Eyal Schachter (Scimonster).

The original C and JavaScript code was written by Danny Sadinoff, with contributions by Michael J. Radwin.

Expand Down Expand Up @@ -252,6 +253,8 @@ See `Hebcal.holidays` for more information on creating an event.

Find the Shabbat on which a given parsha is read. The parsha name (first argument) should correspond to the language string ('s', 'a', or 'h') in the second argument. If no second argument is provided, the parsha should be in Sfardit.

As of v2.2.1, the language string is ignored and checks all languages by default.

This method was added in v2.1.

#### `Hebcal.prototype.findParsha(parsha, o)`
Expand Down Expand Up @@ -1286,4 +1289,4 @@ A shortcut for `month.days.map(mapFunc, [thisArg])`.

That's it! You now know everything there is to know about Hebcal JavaScript! Good luck with whatever you choose to do with it!

If you have any other requests for features, drop me an issue or even a pull request.
If you have any other requests for features, just create an issue or even a pull request.
19 changes: 11 additions & 8 deletions hdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,12 @@ function fixMonth(date) {
}
if (date.month < 1) {
date.month += MONTH_CNT(date.year);
date.year -= 1;
fix(date);
}
if (date.month > MONTH_CNT(date.year)) {
date.month -= MONTH_CNT(date.year);
date.year += 1;
fix(date);
}
}
Expand All @@ -178,7 +180,8 @@ prototype[getMonth] = function() {
};

prototype.getTishreiMonth = function() {
return (this[getMonth]() + MONTH_CNT(this[getFullYear]()) - 6) % MONTH_CNT(this[getFullYear]());
var nummonths = MONTH_CNT(this[getFullYear]());
return (this[getMonth]() + nummonths - 6) % nummonths || nummonths;
};

prototype.daysInMonth = function() {
Expand Down Expand Up @@ -221,7 +224,7 @@ prototype.setDate = function(date) {
Gregorian date Sunday, December 31, 1 BC. */
function hebrew2abs(d) {
var m, tempabs = d[getDate](), year = d[getFullYear]();

if (d[getMonth]() < TISHREI) {
for (m = TISHREI; m <= MONTH_CNT(year); m++) {
tempabs += daysInMonth(m, year);
Expand All @@ -235,7 +238,7 @@ function hebrew2abs(d) {
tempabs += daysInMonth(m, year);
}
}

return c.hebElapsedDays(year) - 1373429 + tempabs;
}

Expand All @@ -248,10 +251,10 @@ function abs2hebrew(d) {
if (d >= 10555144) {
throw new RangeError("parameter to abs2hebrew " + d + " out of range");
}

gregdate = greg.abs2greg(d);
hebdate = new HDate(1, TISHREI, (year = 3760 + gregdate[getFullYear]()));

while (d >= hebrew2abs(hebdate.setFullYear(year + 1))) {
year++;
}
Expand Down Expand Up @@ -417,11 +420,11 @@ HDate.addZeman = function(zeman, func) {
};

prototype.next = function() {
return abs2hebrew(this.abs() + 1);
return abs2hebrew(this.abs() + 1).setLocation(this.lat, this.long);
};

prototype.prev = function() {
return abs2hebrew(this.abs() - 1);
return abs2hebrew(this.abs() - 1).setLocation(this.lat, this.long);
};

prototype.isSameDate = function(other) {
Expand Down Expand Up @@ -458,4 +461,4 @@ prototype.after = function(day) {
return onOrBefore(day, this, 7);
};

module.exports = HDate;
module.exports = HDate;
10 changes: 8 additions & 2 deletions hebcal.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,12 @@ HebcalProto.addHoliday = function(holiday) {
return this;
};

HebcalProto.findParsha = function(parsha, o) {
HebcalProto.findParsha = function(parsha) {
var langs = o ? [o] : ['s','a','h']; // FIXME: abstract this away somewhere
var days = this.filter(function(d){
return d.getSedra(o).indexOf(parsha) + 1;
return Math.max.apply(null, langs.map(function(l){
return d.getSedra(l).indexOf(parsha) + 1;
}));
});
return days[days[length] - 1];
};
Expand Down Expand Up @@ -723,6 +726,9 @@ HDateProto.hallel = (function() {
refreshInterval = ms;
if (ms) {
refresh = setInterval(checkTimes, ms);
if (refresh.unref) {
refresh.unref(); // don't keep the process open
}
}
}));

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hebcal",
"version": "2.2.0",
"version": "2.2.1",
"author": "Eyal Schachter (https://github.com/Scimonster)",
"contributors": [
"Michael J. Radwin (https://github.com/mjradwin)",
Expand Down Expand Up @@ -39,4 +39,4 @@
"url": "https://github.com/hebcal/hebcal-js.git"
},
"readmeFilename": "README.md"
}
}
14 changes: 7 additions & 7 deletions sedra.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,12 @@ Sedra.prototype.get = function(hDate) {
function abs(year, absDate) {

// find the first saturday on or after today's date
var absDate = c.dayOnOrBefore(6, absDate + 6);
absDate = c.dayOnOrBefore(6, absDate + 6);

var weekNum = (absDate - year.first_saturday) / 7;
var index = year.theSedraArray[weekNum];
if (undefined == index) {

if (undefined === index) {
return abs(new Sedra(year.year + 1, year.il), absDate); // must be next year
}
if (typeof index == 'object') {
Expand All @@ -318,9 +318,9 @@ function abs(year, absDate) {
if (index >= 0) {
return [parshiot[index]];
}

index = D(index); // undouble the parsha
return [parshiot[index], parshiot[index + 1]];
};
}

module.exports = Sedra;
module.exports = Sedra;

0 comments on commit d527dcd

Please sign in to comment.