UNPKG

date-object

Version:

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

2 lines (1 loc) 919 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).julian=t()}(this,(function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}return e({name:"julian",startYear:1,yearLength:365,epoch:1721422,century:20,weekStartDayIndex:1,getMonthLengths:e=>[31,e?29:28,31,30,31,30,31,31,30,31,30,31],isLeap:e=>e%4==0,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=>(e-1)/4|0,guessYear:(e,t)=>~~(e/365.25)+(t>0?1:-1)})}));