calendar-dates
Advanced tools
Comparing version
@@ -1,1 +0,1 @@ | ||
"use strict";var classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),CalendarDates=function(){function e(){classCallCheck(this,e)}return createClass(e,[{key:"getDateMatrix",value:function(e){return this.getDates(e).reduce(function(e,t,n){return(n%7==0?e.push([t]):e[e.length-1].push(t))&&e},[])}},{key:"getDates",value:function(e){var t=[],n=this.getPreviousDates(e),a=this.getCurrentDates(e);t=t.concat(n).concat(a);var r=this.getNextDates(e,t.length);return t=t.concat(r)}},{key:"getCurrentDates",value:function(e){var t=getLastDate(e);return Array(t).fill().map(function(e,t){return t+1})}},{key:"getPreviousDates",value:function(e){var t=e.getMonth(),n=e.getFullYear(),a=Math.min(t-1,11),r=getLastDate(new Date(n,a)),u=r-getFirstDayIndex(e)+1;return Array(r-u+1).fill().map(function(e,t){return u+t})}},{key:"getNextDates",value:function(e,t){return Array(42-t).fill().map(function(e,t){return t+1})}}]),e}();function getLastDate(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function getFirstDayIndex(e){var t=new Date(e.getFullYear(),e.getMonth(),1).toDateString().substring(0,3);return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].indexOf(t)}module.exports=CalendarDates; | ||
var classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}(),CalendarDates=function(){function e(){classCallCheck(this,e)}return createClass(e,[{key:"getDateMatrix",value:function(e){return this.getDates(e).reduce(function(e,t,n){return(n%7==0?e.push([t]):e[e.length-1].push(t))&&e},[])}},{key:"getDates",value:function(e){var t=[],n=this.getPreviousDates(e),a=this.getCurrentDates(e);t=t.concat(n).concat(a);var r=this.getNextDates(e,t.length);return t=t.concat(r)}},{key:"getCurrentDates",value:function(e){var t=getLastDate(e);return Array(t).fill().map(function(e,t){return t+1})}},{key:"getPreviousDates",value:function(e){var t=e.getMonth(),n=e.getFullYear(),a=Math.min(t-1,11),r=getLastDate(new Date(n,a)),u=r-getFirstDayIndex(e)+1;return Array(r-u+1).fill().map(function(e,t){return u+t})}},{key:"getNextDates",value:function(e,t){return Array(42-t).fill().map(function(e,t){return t+1})}}]),e}();function getLastDate(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function getFirstDayIndex(e){var t=new Date(e.getFullYear(),e.getMonth(),1).toDateString().substring(0,3);return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"].indexOf(t)}export default CalendarDates; |
{ | ||
"name": "calendar-dates", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "Sung Kim", |
@@ -16,3 +16,3 @@ import resolve from "rollup-plugin-node-resolve"; | ||
file: "dist/calendardates.esm.js", | ||
format: "cjs", | ||
format: "es", | ||
name: "calendar-dates" | ||
@@ -19,0 +19,0 @@ } |
316408
0