UNPKG

ilib

Version:

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

1 lines 1.05 kB
var MathUtils=require("./MathUtils.js"),PersianAlgoCal=require("./PersianAlgoCal.js"),RataDie=require("./RataDie.js"),PersAlgoRataDie=function(params){this.cal=params&&params.cal||new PersianAlgoCal(),this.rd=NaN,RataDie.call(this,params)};PersAlgoRataDie.prototype=new RataDie(),PersAlgoRataDie.prototype.parent=RataDie,(PersAlgoRataDie.prototype.constructor=PersAlgoRataDie).prototype.epoch=1948319.5,PersAlgoRataDie.cumMonthLengths=[0,31,62,93,124,155,186,216,246,276,306,336,365],PersAlgoRataDie.prototype._setDateComponents=function(date){var year=this.cal.equivalentCycleYear(date.year),y=date.year-(0<=date.year?474:473),rdOfYears=1029983*Math.floor(y/2820)+365*(year-1)+Math.floor((682*year-110)/2816),dayInYear=(1<date.month?PersAlgoRataDie.cumMonthLengths[date.month-1]:0)+date.day,rdtime=(36e5*date.hour+6e4*date.minute+1e3*date.second+date.millisecond)/864e5;this.rd=rdOfYears+dayInYear+rdtime},PersAlgoRataDie.prototype._onOrBefore=function(rd,dayOfWeek){return rd-MathUtils.mod(Math.floor(rd)-dayOfWeek-3,7)},module.exports=PersAlgoRataDie;