date-object
Version:
JavaScript library for working with Date and Time in different calendars and locals
2 lines (1 loc) • 980 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).indian=t()}(this,(function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}return e({name:"indian",startYear:0,yearLength:365,epoch:1749628,century:19,weekStartDayIndex:1,getMonthLengths:e=>[e?31:30,31,31,31,31,31,30,30,30,30,30,30],isLeap:e=>(e+=78)%4==0&&e%100!=0||e%400==0,getLeaps(e){let t=0,n=[];for(;e>0?t<=e:e<=t;)this.isLeap(t)&&n.push(t),e>0?t++:t--;return n},getDayOfYear({year:e,month:{number:t},day:n}){let a=this.getMonthLengths(this.isLeap(e));for(let e=0;e<t-1;e++)n+=a[e];return n},getAllDays(e){const{year:t}=e;return this.yearLength*t+(this.leapsLength(t+78)-this.leapsLength(78))+this.getDayOfYear(e)},leapsLength:e=>((e-1)/4|0)+(-(e-1)/100|0)+((e-1)/400|0),guessYear:(e,t)=>~~(e/365.24)+(t>0?1:-1)})}));