src/hebcal.js
function Hebcal(year, month) {
	var me = this; // whenever this is done, it is for optimizations.
	if (!year) {
		year = (new HDate())[getFullYear](); // this year;
	}
	if (typeof year !== 'number') {
		throw new TE('year to Hebcal() is not a number');
	}
	me.year = year;
	if (month) {
		if (typeof month == 'string') {
			month = c.monthFromName(month);
		}
		if (typeof month == 'number') {
			month = [month];
		}

		if (Array.isArray(month)) {
			me.months = month[map](function(i){
				var m = new Month(i, year);
				defProp(m, '__year', {
					configurable: true,
					writable: true,
					value: me
				});
				return m;
			});

			me.holidays = holidays.year(year);
		} else {
			throw new TE('month to Hebcal is not a valid type');
		}
	} else {
		return new Hebcal(year, c.range(1, c.MONTH_CNT(year)));
	}

	me[length] = c.daysInYear(year);

	defProp(me, 'il', getset(function() {
		return me[getMonth](1).il;
	}, function(il) {
		me.months.forEach(function(m){
			m.il = il;
		});
	}));

	defProp(me, 'lat', getset(function() {
		return me[getMonth](1).lat;
	}, function(lat) {
		me.months.forEach(function(m){
			m.lat = lat;
		});
	}));
	defProp(me, 'long', getset(function() {
		return me[getMonth](1).long;
	}, function(lon) {
		me.months.forEach(function(m){
			m.long = lon;
		});
	}));
}
function Hebcal(year, month) {
	var me = this; // whenever this is done, it is for optimizations.
	if (!year) {
		year = (new HDate())[getFullYear](); // this year;
	}
	if (typeof year !== 'number') {
		throw new TE('year to Hebcal() is not a number');
	}
	me.year = year;
	if (month) {
		if (typeof month == 'string') {
			month = c.monthFromName(month);
		}
		if (typeof month == 'number') {
			month = [month];
		}

		if (Array.isArray(month)) {
			me.months = month[map](function(i){
				var m = new Month(i, year);
				defProp(m, '__year', {
					configurable: true,
					writable: true,
					value: me
				});
				return m;
			});

			me.holidays = holidays.year(year);
		} else {
			throw new TE('month to Hebcal is not a valid type');
		}
	} else {
		return new Hebcal(year, c.range(1, c.MONTH_CNT(year)));
	}

	me[length] = c.daysInYear(year);

	defProp(me, 'il', getset(function() {
		return me[getMonth](1).il;
	}, function(il) {
		me.months.forEach(function(m){
			m.il = il;
		});
	}));

	defProp(me, 'lat', getset(function() {
		return me[getMonth](1).lat;
	}, function(lat) {
		me.months.forEach(function(m){
			m.lat = lat;
		});
	}));
	defProp(me, 'long', getset(function() {
		return me[getMonth](1).long;
	}, function(lon) {
		me.months.forEach(function(m){
			m.long = lon;
		});
	}));
}
function Hebcal ( year , month ) { var me = this ; // whenever this is done, it is for optimizations. if ( ! year ) { year = ( new HDate ( ) ) [ getFullYear ] ( ) ; // this year; } if ( typeof year !== 'number' ) { throw new TE ( 'year to Hebcal() is not a number' ) ; } me . year = year ; if ( month ) { if ( typeof month == 'string' ) { month = c . monthFromName ( month ) ; } if ( typeof month == 'number' ) { month = [ month ] ; } if ( Array . isArray ( month ) ) { me . months = month [ map ] ( function ( i ) { var m = new Month ( i , year ) ; defProp ( m , '__year' , { configurable : true , writable : true , value : me } ) ; return m ; } ) ; me . holidays = holidays . year ( year ) ; } else { throw new TE ( 'month to Hebcal is not a valid type' ) ; } } else { return new Hebcal ( year , c . range ( 1 , c . MONTH_CNT ( year ) ) ) ; } me [ length ] = c . daysInYear ( year ) ; defProp ( me , 'il' , getset ( function ( ) { return me [ getMonth ] ( 1 ) . il ; } , function ( il ) { me . months . forEach ( function ( m ) { m . il = il ; } ) ; } ) ) ; defProp ( me , 'lat' , getset ( function ( ) { return me [ getMonth ] ( 1 ) . lat ; } , function ( lat ) { me . months . forEach ( function ( m ) { m . lat = lat ; } ) ; } ) ) ; defProp ( me , 'long' , getset ( function ( ) { return me [ getMonth ] ( 1 ) . long ; } , function ( lon ) { me . months . forEach ( function ( m ) { m . long = lon ; } ) ; } ) ) ; }
Main Hebcal function
Main Hebcal function