date-object
Version:
JavaScript library for working with Date and Time in different calendars and locals
2 lines (1 loc) • 933 B
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).jalali=t()}(this,(function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}return e({name:"jalali",startYear:1,yearLength:365,epoch:1948319,century:14,weekStartDayIndex:0,getMonthLengths:e=>[31,31,31,31,31,31,30,30,30,30,30,e?30:29],isLeap:e=>(e+12)%33%4==1,getLeaps(e){if(0===e)return;let t=e>0?1:-1,n=[];for(;e>0?t<=e:e<=t;)this.isLeap(t)&&n.push(t),e>0?t++:t--;return n},getDayOfYear:({month:{index:e},day:t})=>(e<=6?31*e:186+30*(e-6))+t,getAllDays(e){const{year:t}=e;return this.yearLength*(t-1)+this.leapsLength(t)+this.getDayOfYear(e)},leapsLength(e){return(682*(474+((t=e-474)-(n=2820)*(t/n|0)))-110)/2816|0;var t,n},guessYear:(e,t)=>~~((e+.5)/365.241)+(t>0?1:-1)})}));