text: var ilib=require("./ilib.js");var MathUtils=require("./MathUtils.js");var Locale=require("./Locale.js");var LocaleInfo=require("./LocaleInfo.js");var IDate=require("./IDate.js");var TimeZone=require("./TimeZone.js");var Calendar=require("./Calendar.js");var HebrewCal=require("./HebrewCal.js");var HebrewRataDie=require("./HebrewRataDie.js");var HebrewDate=function(params){this.cal=new HebrewCal();if(params){if(params.timezone){this.timezone=params.timezone}if(params.locale){this.locale=typeof params.locale==="string"?new Locale(params.locale):params.locale;if(!this.timezone){var li=new LocaleInfo(this.locale);this.timezone=li.getTimeZone()}}if(params.year||params.month||params.day||params.hour||params.minute||params.second||params.millisecond||params.parts){this.year=parseInt(params.year,10)||0;this.month=parseInt(params.month,10)||1;this.day=parseInt(params.day,10)||1;this.hour=parseInt(params.hour,10)||0;if(typeof params.parts!=="undefined"){this.parts=parseInt(params.parts,10);var seconds=parseInt(params.parts,10)*3.333333333333;this.minute=Math.floor(seconds/60);seconds-=this.minute*60;this.second=Math.floor(seconds);this.millisecond=seconds-this.second}else{this.minute=parseInt(params.minute,10)||0;this.second=parseInt(params.second,10)||0;this.millisecond=parseInt(params.millisecond,10)||0}this.dayOfYear=parseInt(params.dayOfYear,10);if(typeof params.dst==="boolean"){this.dst=params.dst}this.rd=this.newRd(this);if(!this.tz){this.tz=new TimeZone({id:this.timezone})}this.offset=this.tz._getOffsetMillisWallTime(this)/864e5;if(this.offset!==0){this.rd=this.newRd({rd:this.rd.getRataDie()-this.offset})}}}if(!this.rd){this.rd=this.newRd(params);this._calcDateComponents()}};HebrewDate.prototype=new IDate({noinstance:true});HebrewDate.prototype.parent=IDate;HebrewDate.prototype.constructor=HebrewDate;HebrewDate.cumMonthLengthsReverse=[[0,7],[30,8],[59,9],[88,10],[117,11],[147,12],[176,1],[206,2],[235,3],[265,4],[294,5],[324,6],[354,7]];HebrewDate.cumMonthLengthsLeapReverse=[[0,7],[30,8],[59,9],[88,10],[117,11],[147,12],[177,13],[206,1],[236,2],[265,3],[295,4],[324,5],[354,6],[384,7]];HebrewDate.GregorianDiff=1373060.25;HebrewDate.prototype.newRd=function(params){return new HebrewRataDie(params)};HebrewDate.prototype._calcYear=function(rd){var year,approximation,nextNewYear;approximation=Math.floor(rd/365.246822206)+1;year=approximation;nextNewYear=HebrewCal.newYear(year);while(rd>=nextNewYear){year++;nextNewYear=HebrewCal.newYear(year)}return year-1};HebrewDate.prototype._calcDateComponents=function(){var remainder,i,table,target,rd=this.rd.getRataDie();if(typeof this.offset==="undefined"){this.year=this._calcYear(rd);if(!this.tz){this.tz=new TimeZone({id:this.timezone})}this.offset=this.tz.getOffsetMillis(this)/864e5}if(this.offset!==0){rd+=this.offset;this.year=this._calcYear(rd)}remainder=rd-HebrewCal.newYear(this.year);if(remainder>=59){if(remainder>=88){if(HebrewCal.longKislev(this.year)){remainder--}}if(HebrewCal.longHeshvan(this.year)){remainder--}}table=this.cal.isLeapYear(this.year)?HebrewDate.cumMonthLengthsLeapReverse:HebrewDate.cumMonthLengthsReverse;i=0;target=Math.floor(remainder);while(i+1<table.length&&target>=table[i+1][0]){i++}this.month=table[i][1];remainder-=table[i][0];this.day=Math.floor(remainder);remainder-=this.day;this.day++;remainder=Math.round(remainder*864e5);this.hour=Math.floor(remainder/36e5);remainder-=this.hour*36e5;if(this.hour>=6){this.hour-=6}else{this.hour+=18}this.minute=Math.floor(remainder/6e4);remainder-=this.minute*6e4;this.second=Math.floor(remainder/1e3);remainder-=this.second*1e3;this.millisecond=Math.floor(remainder)};HebrewDate.prototype.getDayOfWeek=function(){var rd=Math.floor(this.rd.getRataDie()+(this.offset||0));return MathUtils.mod(rd+1,7)};HebrewDate.prototype.getHalaqim=function(){if(this.parts<0){var h=this.minute*6e4+this.second*1e3+this.millisecond;this.parts=h*3e-4}return this.parts};HebrewDate.prototype.firstSunday=function(year){var tishri1=this.newRd({year:year,month:7,day:1,hour:18,minute:0,second:0,millisecond:0,cal:this.cal});var firstThu=this.newRd({rd:tishri1.onOrAfter(4),cal:this.cal});return firstThu.before(0)};HebrewDate.prototype.getDayOfYear=function(){var table=this.cal.isLeapYear(this.year)?HebrewRataDie.cumMonthLengthsLeap:HebrewRataDie.cumMonthLengths;var days=table[this.month-1];if((this.month<7||this.month>8)&&HebrewCal.longHeshvan(this.year)){days++}if((this.month<7||this.month>9)&&HebrewCal.longKislev(this.year)){days++}return days+this.day};HebrewDate.prototype.getWeekOfMonth=function(locale){var li=new LocaleInfo(locale),first=this.newRd({year:this.year,month:this.month,day:1,hour:18,minute:0,second:0,millisecond:0}),rd=this.rd.getRataDie(),weekStart=first.onOrAfter(li.getFirstDayOfWeek());if(weekStart-first.getRataDie()>3){weekStart-=7}return rd<weekStart?0:Math.floor((rd-weekStart)/7)+1};HebrewDate.prototype.getEra=function(){return this.year<1?-1:1};HebrewDate.prototype.getCalendar=function(){return"hebrew"};IDate._constructors["hebrew"]=HebrewDate;module.exports=HebrewDate;