UNPKG

date-object

Version:

JavaScript library for working with Date and Time in different calendars and locals

2 lines (1 loc) 972 B
!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).arabic=t()}(this,(function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}return e({name:"arabic",startYear:1,yearLength:354,epoch:1948438,century:14,weekStartDayIndex:0,getMonthLengths:e=>[30,29,30,29,30,29,30,29,30,29,30,e?30:29],isLeap:e=>[2,5,7,10,13,15,18,21,24,26,29].includes(e%30),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({year:e,month:t,day:n}){let a=this.getMonthLengths(this.isLeap(e));for(let e=0;e<t.index;e++)n+=a[e];return n},getAllDays(e){const{year:t}=e;return this.yearLength*(t-1)+this.leapsLength(t)+this.getDayOfYear(e)},leapsLength:e=>11/30*(e-1)+.5|0,guessYear:(e,t)=>~~((e-.5)/354.366)+(t>0?1:-1)})}));