hebcal / hebcal-js

⛔️ DEPRECATED - a perpetual Jewish Calendar (JavaScript)
GNU General Public License v3.0
124 stars 40 forks source link

Allow for arguments in HDate.prev() #78

Open mennyg opened 4 years ago

mennyg commented 4 years ago

HDate.prev() currently only allows to go back one day. It would be great if we can be allowed to add arguments. Fro example, Hebcal.HDate.prev(7) would give me last week, and .prev(30) would give me a month ago.

Scimonster commented 4 years ago

Good idea! Would you be interesting in making a pull request with this?

mennyg commented 4 years ago

Would love to, but I'm quite new to extended functions and prototypes. Here is what I'm thinking, but it's not working on my side (hdate.js):

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

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