UNPKG

@js-sugar/date

Version:

A multi-calendar, tree-shakable, extensible, immutable and lightweight date library for JavaScript

1 lines 1.29 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["jss-date"]=t():e["jss-date"]=t()}(this,(function(){return(this.webpackChunkjss_date=this.webpackChunkjss_date||[]).push([[229],{733:(e,t,n)=>{"use strict";n.r(t),n.d(t,{GregorianCalendar:()=>GregorianCalendar});var r=n(157);class GregorianCalendar extends r.Calendar{constructor(e){super(e,"gregory")}addMonths(e,t){const n=new Date(e);return n.setMonth(n.getMonth()+t),n.getTime()}addYears(e,t){return this.addMonths(e,12*t)}dayOfYear(e){const t=new Date(e),n=new Date(t.getFullYear(),0,0),s=t.getTime()-n.getTime();return Math.floor(s/r.MS_PER_DAY)}daysInMonth(e,t){const n=this.isLeapYear(e)?r.DAYS_TO_MONTH_366:r.DAYS_TO_MONTH_365;return n[t]-n[t-1]}daysInYear(e){return this.isLeapYear(e)?366:365}isLeapYear(e){return e%4==0&&(e%100!=0||e%400==0)}getTimestamp(e){const t=e;return Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute,t.second,t.ms)}getUnits(e){return Object.assign(Object.assign({},function(e){const t=new Date(e);return{year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate(),hour:0,minute:0,second:0,ms:0}}(e)),(0,r.getTimeUnits)(e))}}}},e=>{"use strict";var t;return t=733,e(e.s=t)}])}));