UNPKG

ilib

Version:

iLib is a cross-engine library of internationalization (i18n) classes written in pure JS

1 lines 1.25 kB
var MathUtils=require("./MathUtils.js"),GregorianCal=require("./GregorianCal.js"),RataDie=require("./RataDie.js"),GregRataDie=function(params){this.cal=params&&params.cal||new GregorianCal(),this.rd=NaN,RataDie.call(this,params)};GregRataDie.prototype=new RataDie(),GregRataDie.prototype.parent=RataDie,(GregRataDie.prototype.constructor=GregRataDie).cumMonthLengths=[0,31,59,90,120,151,181,212,243,273,304,334,365],GregRataDie.cumMonthLengthsLeap=[0,31,60,91,121,152,182,213,244,274,305,335,366],GregRataDie.prototype._setDateComponents=function(date){var year=parseInt(date.year,10)||0,month=parseInt(date.month,10)||1,day=parseInt(date.day,10)||1,hour=parseInt(date.hour,10)||0,minute=parseInt(date.minute,10)||0,second=parseInt(date.second,10)||0,millisecond=parseInt(date.millisecond,10)||0,years=365*(year-1)+Math.floor((year-1)/4)-Math.floor((year-1)/100)+Math.floor((year-1)/400),dayInYear=(1<month?GregRataDie.cumMonthLengths[month-1]:0)+day+(GregorianCal.prototype.isLeapYear.call(this.cal,year)&&2<month?1:0),rdtime=(36e5*hour+6e4*minute+1e3*second+millisecond)/864e5;this.rd=years+dayInYear+rdtime},GregRataDie.prototype._onOrBefore=function(rd,dayOfWeek){return rd-MathUtils.mod(Math.floor(rd)-dayOfWeek,7)},module.exports=GregRataDie;