Comparing version 1.2.2 to 1.2.3
@@ -119,3 +119,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.backwardCompatibility = exports.easyDate = exports.EasyDate = undefined;\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _dateFormat = __webpack_require__(/*! ./date-format */ \"./src/date-format.js\");\n\nvar _dateFormat2 = _interopRequireDefault(_dateFormat);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar EasyDate = function (_Date) {\n _inherits(EasyDate, _Date);\n\n function EasyDate() {\n _classCallCheck(this, EasyDate);\n\n return _possibleConstructorReturn(this, (EasyDate.__proto__ || Object.getPrototypeOf(EasyDate)).apply(this, arguments));\n }\n\n _createClass(EasyDate, null, [{\n key: \"formatDate\",\n value: function formatDate(date, mask) {\n if (!!mask) {\n return (0, _dateFormat2.default)(date, mask);\n } else {\n return date;\n }\n }\n }, {\n key: \"today\",\n value: function today(mask) {\n return EasyDate.formatDate(new Date(), mask);\n }\n }, {\n key: \"yesterday\",\n value: function yesterday(mask) {\n return new EasyD(1, 'day').ago(mask);\n }\n }, {\n key: \"tomorrow\",\n value: function tomorrow(mask) {\n return new EasyD(1, 'day').fromNow(mask);\n }\n }]);\n\n return EasyDate;\n}(Date);\n\nvar EasyD = function () {\n function EasyD(value, conversionType) {\n _classCallCheck(this, EasyD);\n\n _initialiseProps.call(this);\n\n this.value = parseInt(value);\n this.conversionType = conversionType;\n }\n\n _createClass(EasyD, [{\n key: \"fromNow\",\n value: function fromNow(mask) {\n var processor = this.process(mask);\n if (processor) {\n return processor.fromNow();\n } else {\n return \"Processor not found.\";\n }\n }\n }, {\n key: \"ago\",\n value: function ago(mask) {\n var processor = this.process(mask);\n if (processor) {\n return processor.ago();\n } else {\n return \"Processor not found.\";\n }\n }\n }, {\n key: \"since\",\n value: function since(date, mask) {\n this.now = new Date(date.valueOf());\n return this.fromNow(mask);\n }\n }, {\n key: \"until\",\n value: function until(date, mask) {\n this.now = new Date(date.valueOf());\n return this.ago(mask);\n }\n }, {\n key: \"before\",\n value: function before(date, mask) {\n return this.until(date, mask);\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return this.value + \" \" + this.conversionType + (this.value > 1 ? 's' : '');\n }\n }, {\n key: \"process\",\n value: function process(mask) {\n var conversionType = this.conversionType,\n timeProcessor = this.timeProcessor;\n\n var now = this.now || new Date();\n return {\n hour: function hour() {\n return timeProcessor(now, now.setHours, now.getHours, mask);\n },\n day: function day() {\n return timeProcessor(now, now.setDate, now.getDate, mask);\n },\n week: function week() {\n return null;\n },\n month: function month() {\n return timeProcessor(now, now.setMonth, now.getMonth, mask);\n },\n year: function year() {\n return timeProcessor(now, now.setFullYear, now.getFullYear, mask);\n }\n }[conversionType]();\n }\n }]);\n\n return EasyD;\n}();\n\nvar _initialiseProps = function _initialiseProps() {\n var _this2 = this;\n\n this.timeProcessor = function (now, set, get, mask) {\n var value = _this2.value;\n\n return {\n ago: function ago() {\n set.call(now, get.call(now) - value);\n return EasyDate.formatDate(now, mask);\n },\n fromNow: function fromNow() {\n set.call(now, get.call(now) + value);\n return EasyDate.formatDate(now, mask);\n }\n };\n };\n};\n\nfunction easyDate(value) {\n var days = function days() {\n return new EasyD(value, 'day');\n };\n\n var months = function months() {\n return new EasyD(value, 'month');\n };\n\n var years = function years() {\n return new EasyD(value, 'year');\n };\n\n var hours = function hours() {\n return new EasyD(value, 'hour');\n };\n\n return {\n hour: hours,\n hours: hours,\n day: days,\n days: days,\n month: months,\n months: months,\n year: years,\n years: years\n };\n}\n\nfunction backwardCompatibility() {\n\n var days = function days() {\n return new EasyD(this, 'day');\n };\n\n var months = function months() {\n return new EasyD(this, 'month');\n };\n\n var years = function years() {\n return new EasyD(this, 'year');\n };\n\n var hours = function hours() {\n return new EasyD(this, 'hour');\n };\n\n // $FlowFixMe\n Number.prototype.day = days;\n // $FlowFixMe\n Number.prototype.days = days;\n // $FlowFixMe\n Number.prototype.month = months;\n // $FlowFixMe\n Number.prototype.months = months;\n // $FlowFixMe\n Number.prototype.years = years;\n // $FlowFixMe\n Number.prototype.year = years;\n // $FlowFixMe\n Number.prototype.hours = hours;\n // $FlowFixMe\n Number.prototype.hour = hours;\n\n // $FlowFixMe\n Object.assign(Date, {\n today: function today(mask) {\n return EasyDate.today(mask);\n },\n yesterday: function yesterday(mask) {\n return EasyDate.yesterday(mask);\n },\n tomorrow: function tomorrow(mask) {\n return EasyDate.tomorrow(mask);\n },\n tommorrow: function tommorrow(mask) {\n return EasyDate.tomorrow(mask);\n }\n });\n}\n\nexports.EasyDate = EasyDate;\nexports.easyDate = easyDate;\nexports.backwardCompatibility = backwardCompatibility;\n\n//# sourceURL=webpack:///./src/easy-date.js?"); | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.backwardCompatibility = exports.easyDate = exports.EasyDate = undefined;\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _dateFormat = __webpack_require__(/*! ./date-format */ \"./src/date-format.js\");\n\nvar _dateFormat2 = _interopRequireDefault(_dateFormat);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar EasyDate = function () {\n function EasyDate(date) {\n _classCallCheck(this, EasyDate);\n\n this._date = date;\n }\n\n _createClass(EasyDate, [{\n key: \"getDate\",\n value: function getDate() {\n return this._date;\n }\n }, {\n key: \"format\",\n value: function format(mask) {\n return (0, _dateFormat2.default)(this._date, mask);\n }\n }], [{\n key: \"formatDate\",\n value: function formatDate(date, mask) {\n if (!!mask) {\n return (0, _dateFormat2.default)(date, mask);\n } else {\n return date;\n }\n }\n }, {\n key: \"today\",\n value: function today(mask) {\n return EasyDate.formatDate(new Date(), mask);\n }\n }, {\n key: \"yesterday\",\n value: function yesterday(mask) {\n return new EasyD(1, 'day').ago(mask);\n }\n }, {\n key: \"tomorrow\",\n value: function tomorrow(mask) {\n return new EasyD(1, 'day').fromNow(mask);\n }\n }]);\n\n return EasyDate;\n}();\n\nvar EasyD = function () {\n function EasyD(value, conversionType) {\n _classCallCheck(this, EasyD);\n\n _initialiseProps.call(this);\n\n this.value = parseInt(value);\n this.conversionType = conversionType;\n }\n\n _createClass(EasyD, [{\n key: \"fromNow\",\n value: function fromNow(mask) {\n var processor = this.process(mask);\n if (processor) {\n return processor.fromNow();\n } else {\n return \"Processor not found.\";\n }\n }\n }, {\n key: \"ago\",\n value: function ago(mask) {\n var processor = this.process(mask);\n if (processor) {\n return processor.ago();\n } else {\n return \"Processor not found.\";\n }\n }\n }, {\n key: \"since\",\n value: function since(date, mask) {\n this.now = new Date(date.valueOf());\n return this.fromNow(mask);\n }\n }, {\n key: \"until\",\n value: function until(date, mask) {\n this.now = new Date(date.valueOf());\n return this.ago(mask);\n }\n }, {\n key: \"before\",\n value: function before(date, mask) {\n return this.until(date, mask);\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return this.value + \" \" + this.conversionType + (this.value > 1 ? 's' : '');\n }\n }, {\n key: \"process\",\n value: function process(mask) {\n var conversionType = this.conversionType,\n timeProcessor = this.timeProcessor;\n\n var now = this.now || new Date();\n return {\n hour: function hour() {\n return timeProcessor(now, now.setHours, now.getHours, mask);\n },\n day: function day() {\n return timeProcessor(now, now.setDate, now.getDate, mask);\n },\n week: function week() {\n return null;\n },\n month: function month() {\n return timeProcessor(now, now.setMonth, now.getMonth, mask);\n },\n year: function year() {\n return timeProcessor(now, now.setFullYear, now.getFullYear, mask);\n }\n }[conversionType]();\n }\n }]);\n\n return EasyD;\n}();\n\nvar _initialiseProps = function _initialiseProps() {\n var _this = this;\n\n this.timeProcessor = function (now, set, get, mask) {\n var value = _this.value;\n\n return {\n ago: function ago() {\n set.call(now, get.call(now) - value);\n return EasyDate.formatDate(now, mask);\n },\n fromNow: function fromNow() {\n set.call(now, get.call(now) + value);\n return EasyDate.formatDate(now, mask);\n }\n };\n };\n};\n\nfunction easyDate(value) {\n var days = function days() {\n return new EasyD(value, 'day');\n };\n\n var months = function months() {\n return new EasyD(value, 'month');\n };\n\n var years = function years() {\n return new EasyD(value, 'year');\n };\n\n var hours = function hours() {\n return new EasyD(value, 'hour');\n };\n\n return {\n hour: hours,\n hours: hours,\n day: days,\n days: days,\n month: months,\n months: months,\n year: years,\n years: years\n };\n}\n\nfunction backwardCompatibility() {\n\n var days = function days() {\n return new EasyD(this, 'day');\n };\n\n var months = function months() {\n return new EasyD(this, 'month');\n };\n\n var years = function years() {\n return new EasyD(this, 'year');\n };\n\n var hours = function hours() {\n return new EasyD(this, 'hour');\n };\n\n // $FlowFixMe\n Number.prototype.day = days;\n // $FlowFixMe\n Number.prototype.days = days;\n // $FlowFixMe\n Number.prototype.month = months;\n // $FlowFixMe\n Number.prototype.months = months;\n // $FlowFixMe\n Number.prototype.years = years;\n // $FlowFixMe\n Number.prototype.year = years;\n // $FlowFixMe\n Number.prototype.hours = hours;\n // $FlowFixMe\n Number.prototype.hour = hours;\n\n // $FlowFixMe\n Object.assign(Date, {\n today: function today(mask) {\n return EasyDate.today(mask);\n },\n yesterday: function yesterday(mask) {\n return EasyDate.yesterday(mask);\n },\n tomorrow: function tomorrow(mask) {\n return EasyDate.tomorrow(mask);\n },\n tommorrow: function tommorrow(mask) {\n return EasyDate.tomorrow(mask);\n }\n });\n}\n\nexports.EasyDate = EasyDate;\nexports.easyDate = easyDate;\nexports.backwardCompatibility = backwardCompatibility;\n\n//# sourceURL=webpack:///./src/easy-date.js?"); | ||
@@ -122,0 +122,0 @@ /***/ }), |
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){var e=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,t=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,n=/[^-+\dA-Z]/g,o=function(e,t){for(e=String(e),t=t||2;e.length<t;)e="0"+e;return e};return function(u,a,i){var s=r;if(1!==arguments.length||"[object String]"!==Object.prototype.toString.call(u)||/\d/.test(u)||(a=u,u=void 0),u=u?new Date(u):new Date,isNaN(u))throw SyntaxError("invalid date");"UTC:"===(a=String(s.masks[a]||a||s.masks.default)).slice(0,4)&&(a=a.slice(4),i=!0);var y=i?"getUTC":"get",c=u[y+"Date"](),f=u[y+"Day"](),l=u[y+"Month"](),d=u[y+"FullYear"](),m=u[y+"Hours"](),p=u[y+"Minutes"](),h=u[y+"Seconds"](),b=u[y+"Milliseconds"](),v=i?0:u.getTimezoneOffset(),M={d:c,dd:o(c),ddd:s.i18n.dayNames[f],dddd:s.i18n.dayNames[f+7],m:l+1,mm:o(l+1),mmm:s.i18n.monthNames[l],mmmm:s.i18n.monthNames[l+12],yy:String(d).slice(2),yyyy:d,h:m%12||12,hh:o(m%12||12),H:m,HH:o(m),M:p,MM:o(p),s:h,ss:o(h),l:o(b,3),L:o(b>99?Math.round(b/10):b),t:m<12?"a":"p",tt:m<12?"am":"pm",T:m<12?"A":"P",TT:m<12?"AM":"PM",Z:i?"UTC":(String(u).match(t)||[""]).pop().replace(n,""),o:(v>0?"-":"+")+o(100*Math.floor(Math.abs(v)/60)+Math.abs(v)%60,4),S:["th","st","nd","rd"][c%10>3?0:(c%100-c%10!=10)*c%10]};return a.replace(e,function(e){return e in M?M[e]:e.slice(1,e.length-1)})}}();r.masks={default:"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"},r.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]},void 0===Date.prototype.format&&(Date.prototype.format=function(e,t){return r(this,e,t)}),t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.backwardCompatibility=t.easyDate=t.EasyDate=void 0;var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(e){return e&&e.__esModule?e:{default:e}}(n(0));function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function(e){function t(){return u(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Date),r(t,null,[{key:"formatDate",value:function(e,t){return t?(0,o.default)(e,t):e}},{key:"today",value:function(e){return t.formatDate(new Date,e)}},{key:"yesterday",value:function(e){return new i(1,"day").ago(e)}},{key:"tomorrow",value:function(e){return new i(1,"day").fromNow(e)}}]),t}(),i=function(){function e(t,n){u(this,e),s.call(this),this.value=parseInt(t),this.conversionType=n}return r(e,[{key:"fromNow",value:function(e){var t=this.process(e);return t?t.fromNow():"Processor not found."}},{key:"ago",value:function(e){var t=this.process(e);return t?t.ago():"Processor not found."}},{key:"since",value:function(e,t){return this.now=new Date(e.valueOf()),this.fromNow(t)}},{key:"until",value:function(e,t){return this.now=new Date(e.valueOf()),this.ago(t)}},{key:"before",value:function(e,t){return this.until(e,t)}},{key:"toString",value:function(){return this.value+" "+this.conversionType+(this.value>1?"s":"")}},{key:"process",value:function(e){var t=this.conversionType,n=this.timeProcessor,r=this.now||new Date;return{hour:function(){return n(r,r.setHours,r.getHours,e)},day:function(){return n(r,r.setDate,r.getDate,e)},week:function(){return null},month:function(){return n(r,r.setMonth,r.getMonth,e)},year:function(){return n(r,r.setFullYear,r.getFullYear,e)}}[t]()}}]),e}(),s=function(){var e=this;this.timeProcessor=function(t,n,r,o){var u=e.value;return{ago:function(){return n.call(t,r.call(t)-u),a.formatDate(t,o)},fromNow:function(){return n.call(t,r.call(t)+u),a.formatDate(t,o)}}}};t.EasyDate=a,t.easyDate=function(e){var t=function(){return new i(e,"day")},n=function(){return new i(e,"month")},r=function(){return new i(e,"year")},o=function(){return new i(e,"hour")};return{hour:o,hours:o,day:t,days:t,month:n,months:n,year:r,years:r}},t.backwardCompatibility=function(){var e=function(){return new i(this,"day")},t=function(){return new i(this,"month")},n=function(){return new i(this,"year")},r=function(){return new i(this,"hour")};Number.prototype.day=e,Number.prototype.days=e,Number.prototype.month=t,Number.prototype.months=t,Number.prototype.years=n,Number.prototype.year=n,Number.prototype.hours=r,Number.prototype.hour=r,Object.assign(Date,{today:function(e){return a.today(e)},yesterday:function(e){return a.yesterday(e)},tomorrow:function(e){return a.tomorrow(e)},tommorrow:function(e){return a.tomorrow(e)}})}},,,function(e,t,n){e.exports=n(1)}])}); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){var e=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,t=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,n=/[^-+\dA-Z]/g,o=function(e,t){for(e=String(e),t=t||2;e.length<t;)e="0"+e;return e};return function(u,a,i){var s=r;if(1!==arguments.length||"[object String]"!==Object.prototype.toString.call(u)||/\d/.test(u)||(a=u,u=void 0),u=u?new Date(u):new Date,isNaN(u))throw SyntaxError("invalid date");"UTC:"===(a=String(s.masks[a]||a||s.masks.default)).slice(0,4)&&(a=a.slice(4),i=!0);var y=i?"getUTC":"get",c=u[y+"Date"](),f=u[y+"Day"](),l=u[y+"Month"](),d=u[y+"FullYear"](),m=u[y+"Hours"](),h=u[y+"Minutes"](),p=u[y+"Seconds"](),v=u[y+"Milliseconds"](),b=i?0:u.getTimezoneOffset(),M={d:c,dd:o(c),ddd:s.i18n.dayNames[f],dddd:s.i18n.dayNames[f+7],m:l+1,mm:o(l+1),mmm:s.i18n.monthNames[l],mmmm:s.i18n.monthNames[l+12],yy:String(d).slice(2),yyyy:d,h:m%12||12,hh:o(m%12||12),H:m,HH:o(m),M:h,MM:o(h),s:p,ss:o(p),l:o(v,3),L:o(v>99?Math.round(v/10):v),t:m<12?"a":"p",tt:m<12?"am":"pm",T:m<12?"A":"P",TT:m<12?"AM":"PM",Z:i?"UTC":(String(u).match(t)||[""]).pop().replace(n,""),o:(b>0?"-":"+")+o(100*Math.floor(Math.abs(b)/60)+Math.abs(b)%60,4),S:["th","st","nd","rd"][c%10>3?0:(c%100-c%10!=10)*c%10]};return a.replace(e,function(e){return e in M?M[e]:e.slice(1,e.length-1)})}}();r.masks={default:"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"},r.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]},void 0===Date.prototype.format&&(Date.prototype.format=function(e,t){return r(this,e,t)}),t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.backwardCompatibility=t.easyDate=t.EasyDate=void 0;var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(e){return e&&e.__esModule?e:{default:e}}(n(0));function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function(){function e(t){u(this,e),this._date=t}return r(e,[{key:"getDate",value:function(){return this._date}},{key:"format",value:function(e){return(0,o.default)(this._date,e)}}],[{key:"formatDate",value:function(e,t){return t?(0,o.default)(e,t):e}},{key:"today",value:function(t){return e.formatDate(new Date,t)}},{key:"yesterday",value:function(e){return new i(1,"day").ago(e)}},{key:"tomorrow",value:function(e){return new i(1,"day").fromNow(e)}}]),e}(),i=function(){function e(t,n){u(this,e),s.call(this),this.value=parseInt(t),this.conversionType=n}return r(e,[{key:"fromNow",value:function(e){var t=this.process(e);return t?t.fromNow():"Processor not found."}},{key:"ago",value:function(e){var t=this.process(e);return t?t.ago():"Processor not found."}},{key:"since",value:function(e,t){return this.now=new Date(e.valueOf()),this.fromNow(t)}},{key:"until",value:function(e,t){return this.now=new Date(e.valueOf()),this.ago(t)}},{key:"before",value:function(e,t){return this.until(e,t)}},{key:"toString",value:function(){return this.value+" "+this.conversionType+(this.value>1?"s":"")}},{key:"process",value:function(e){var t=this.conversionType,n=this.timeProcessor,r=this.now||new Date;return{hour:function(){return n(r,r.setHours,r.getHours,e)},day:function(){return n(r,r.setDate,r.getDate,e)},week:function(){return null},month:function(){return n(r,r.setMonth,r.getMonth,e)},year:function(){return n(r,r.setFullYear,r.getFullYear,e)}}[t]()}}]),e}(),s=function(){var e=this;this.timeProcessor=function(t,n,r,o){var u=e.value;return{ago:function(){return n.call(t,r.call(t)-u),a.formatDate(t,o)},fromNow:function(){return n.call(t,r.call(t)+u),a.formatDate(t,o)}}}};t.EasyDate=a,t.easyDate=function(e){var t=function(){return new i(e,"day")},n=function(){return new i(e,"month")},r=function(){return new i(e,"year")},o=function(){return new i(e,"hour")};return{hour:o,hours:o,day:t,days:t,month:n,months:n,year:r,years:r}},t.backwardCompatibility=function(){var e=function(){return new i(this,"day")},t=function(){return new i(this,"month")},n=function(){return new i(this,"year")},r=function(){return new i(this,"hour")};Number.prototype.day=e,Number.prototype.days=e,Number.prototype.month=t,Number.prototype.months=t,Number.prototype.years=n,Number.prototype.year=n,Number.prototype.hours=r,Number.prototype.hour=r,Object.assign(Date,{today:function(e){return a.today(e)},yesterday:function(e){return a.yesterday(e)},tomorrow:function(e){return a.tomorrow(e)},tommorrow:function(e){return a.tomorrow(e)}})}},,,function(e,t,n){e.exports=n(1)}])}); |
@@ -131,3 +131,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
"use strict"; | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.backwardCompatibility = exports.easyDate = exports.EasyDate = undefined;\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _dateFormat = __webpack_require__(/*! ./date-format */ \"./src/date-format.js\");\n\nvar _dateFormat2 = _interopRequireDefault(_dateFormat);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar EasyDate = function (_Date) {\n _inherits(EasyDate, _Date);\n\n function EasyDate() {\n _classCallCheck(this, EasyDate);\n\n return _possibleConstructorReturn(this, (EasyDate.__proto__ || Object.getPrototypeOf(EasyDate)).apply(this, arguments));\n }\n\n _createClass(EasyDate, null, [{\n key: \"formatDate\",\n value: function formatDate(date, mask) {\n if (!!mask) {\n return (0, _dateFormat2.default)(date, mask);\n } else {\n return date;\n }\n }\n }, {\n key: \"today\",\n value: function today(mask) {\n return EasyDate.formatDate(new Date(), mask);\n }\n }, {\n key: \"yesterday\",\n value: function yesterday(mask) {\n return new EasyD(1, 'day').ago(mask);\n }\n }, {\n key: \"tomorrow\",\n value: function tomorrow(mask) {\n return new EasyD(1, 'day').fromNow(mask);\n }\n }]);\n\n return EasyDate;\n}(Date);\n\nvar EasyD = function () {\n function EasyD(value, conversionType) {\n _classCallCheck(this, EasyD);\n\n _initialiseProps.call(this);\n\n this.value = parseInt(value);\n this.conversionType = conversionType;\n }\n\n _createClass(EasyD, [{\n key: \"fromNow\",\n value: function fromNow(mask) {\n var processor = this.process(mask);\n if (processor) {\n return processor.fromNow();\n } else {\n return \"Processor not found.\";\n }\n }\n }, {\n key: \"ago\",\n value: function ago(mask) {\n var processor = this.process(mask);\n if (processor) {\n return processor.ago();\n } else {\n return \"Processor not found.\";\n }\n }\n }, {\n key: \"since\",\n value: function since(date, mask) {\n this.now = new Date(date.valueOf());\n return this.fromNow(mask);\n }\n }, {\n key: \"until\",\n value: function until(date, mask) {\n this.now = new Date(date.valueOf());\n return this.ago(mask);\n }\n }, {\n key: \"before\",\n value: function before(date, mask) {\n return this.until(date, mask);\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return this.value + \" \" + this.conversionType + (this.value > 1 ? 's' : '');\n }\n }, {\n key: \"process\",\n value: function process(mask) {\n var conversionType = this.conversionType,\n timeProcessor = this.timeProcessor;\n\n var now = this.now || new Date();\n return {\n hour: function hour() {\n return timeProcessor(now, now.setHours, now.getHours, mask);\n },\n day: function day() {\n return timeProcessor(now, now.setDate, now.getDate, mask);\n },\n week: function week() {\n return null;\n },\n month: function month() {\n return timeProcessor(now, now.setMonth, now.getMonth, mask);\n },\n year: function year() {\n return timeProcessor(now, now.setFullYear, now.getFullYear, mask);\n }\n }[conversionType]();\n }\n }]);\n\n return EasyD;\n}();\n\nvar _initialiseProps = function _initialiseProps() {\n var _this2 = this;\n\n this.timeProcessor = function (now, set, get, mask) {\n var value = _this2.value;\n\n return {\n ago: function ago() {\n set.call(now, get.call(now) - value);\n return EasyDate.formatDate(now, mask);\n },\n fromNow: function fromNow() {\n set.call(now, get.call(now) + value);\n return EasyDate.formatDate(now, mask);\n }\n };\n };\n};\n\nfunction easyDate(value) {\n var days = function days() {\n return new EasyD(value, 'day');\n };\n\n var months = function months() {\n return new EasyD(value, 'month');\n };\n\n var years = function years() {\n return new EasyD(value, 'year');\n };\n\n var hours = function hours() {\n return new EasyD(value, 'hour');\n };\n\n return {\n hour: hours,\n hours: hours,\n day: days,\n days: days,\n month: months,\n months: months,\n year: years,\n years: years\n };\n}\n\nfunction backwardCompatibility() {\n\n var days = function days() {\n return new EasyD(this, 'day');\n };\n\n var months = function months() {\n return new EasyD(this, 'month');\n };\n\n var years = function years() {\n return new EasyD(this, 'year');\n };\n\n var hours = function hours() {\n return new EasyD(this, 'hour');\n };\n\n // $FlowFixMe\n Number.prototype.day = days;\n // $FlowFixMe\n Number.prototype.days = days;\n // $FlowFixMe\n Number.prototype.month = months;\n // $FlowFixMe\n Number.prototype.months = months;\n // $FlowFixMe\n Number.prototype.years = years;\n // $FlowFixMe\n Number.prototype.year = years;\n // $FlowFixMe\n Number.prototype.hours = hours;\n // $FlowFixMe\n Number.prototype.hour = hours;\n\n // $FlowFixMe\n Object.assign(Date, {\n today: function today(mask) {\n return EasyDate.today(mask);\n },\n yesterday: function yesterday(mask) {\n return EasyDate.yesterday(mask);\n },\n tomorrow: function tomorrow(mask) {\n return EasyDate.tomorrow(mask);\n },\n tommorrow: function tommorrow(mask) {\n return EasyDate.tomorrow(mask);\n }\n });\n}\n\nexports.EasyDate = EasyDate;\nexports.easyDate = easyDate;\nexports.backwardCompatibility = backwardCompatibility;\n\n//# sourceURL=webpack:///./src/easy-date.js?"); | ||
eval("\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.backwardCompatibility = exports.easyDate = exports.EasyDate = undefined;\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _dateFormat = __webpack_require__(/*! ./date-format */ \"./src/date-format.js\");\n\nvar _dateFormat2 = _interopRequireDefault(_dateFormat);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar EasyDate = function () {\n function EasyDate(date) {\n _classCallCheck(this, EasyDate);\n\n this._date = date;\n }\n\n _createClass(EasyDate, [{\n key: \"getDate\",\n value: function getDate() {\n return this._date;\n }\n }, {\n key: \"format\",\n value: function format(mask) {\n return (0, _dateFormat2.default)(this._date, mask);\n }\n }], [{\n key: \"formatDate\",\n value: function formatDate(date, mask) {\n if (!!mask) {\n return (0, _dateFormat2.default)(date, mask);\n } else {\n return date;\n }\n }\n }, {\n key: \"today\",\n value: function today(mask) {\n return EasyDate.formatDate(new Date(), mask);\n }\n }, {\n key: \"yesterday\",\n value: function yesterday(mask) {\n return new EasyD(1, 'day').ago(mask);\n }\n }, {\n key: \"tomorrow\",\n value: function tomorrow(mask) {\n return new EasyD(1, 'day').fromNow(mask);\n }\n }]);\n\n return EasyDate;\n}();\n\nvar EasyD = function () {\n function EasyD(value, conversionType) {\n _classCallCheck(this, EasyD);\n\n _initialiseProps.call(this);\n\n this.value = parseInt(value);\n this.conversionType = conversionType;\n }\n\n _createClass(EasyD, [{\n key: \"fromNow\",\n value: function fromNow(mask) {\n var processor = this.process(mask);\n if (processor) {\n return processor.fromNow();\n } else {\n return \"Processor not found.\";\n }\n }\n }, {\n key: \"ago\",\n value: function ago(mask) {\n var processor = this.process(mask);\n if (processor) {\n return processor.ago();\n } else {\n return \"Processor not found.\";\n }\n }\n }, {\n key: \"since\",\n value: function since(date, mask) {\n this.now = new Date(date.valueOf());\n return this.fromNow(mask);\n }\n }, {\n key: \"until\",\n value: function until(date, mask) {\n this.now = new Date(date.valueOf());\n return this.ago(mask);\n }\n }, {\n key: \"before\",\n value: function before(date, mask) {\n return this.until(date, mask);\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return this.value + \" \" + this.conversionType + (this.value > 1 ? 's' : '');\n }\n }, {\n key: \"process\",\n value: function process(mask) {\n var conversionType = this.conversionType,\n timeProcessor = this.timeProcessor;\n\n var now = this.now || new Date();\n return {\n hour: function hour() {\n return timeProcessor(now, now.setHours, now.getHours, mask);\n },\n day: function day() {\n return timeProcessor(now, now.setDate, now.getDate, mask);\n },\n week: function week() {\n return null;\n },\n month: function month() {\n return timeProcessor(now, now.setMonth, now.getMonth, mask);\n },\n year: function year() {\n return timeProcessor(now, now.setFullYear, now.getFullYear, mask);\n }\n }[conversionType]();\n }\n }]);\n\n return EasyD;\n}();\n\nvar _initialiseProps = function _initialiseProps() {\n var _this = this;\n\n this.timeProcessor = function (now, set, get, mask) {\n var value = _this.value;\n\n return {\n ago: function ago() {\n set.call(now, get.call(now) - value);\n return EasyDate.formatDate(now, mask);\n },\n fromNow: function fromNow() {\n set.call(now, get.call(now) + value);\n return EasyDate.formatDate(now, mask);\n }\n };\n };\n};\n\nfunction easyDate(value) {\n var days = function days() {\n return new EasyD(value, 'day');\n };\n\n var months = function months() {\n return new EasyD(value, 'month');\n };\n\n var years = function years() {\n return new EasyD(value, 'year');\n };\n\n var hours = function hours() {\n return new EasyD(value, 'hour');\n };\n\n return {\n hour: hours,\n hours: hours,\n day: days,\n days: days,\n month: months,\n months: months,\n year: years,\n years: years\n };\n}\n\nfunction backwardCompatibility() {\n\n var days = function days() {\n return new EasyD(this, 'day');\n };\n\n var months = function months() {\n return new EasyD(this, 'month');\n };\n\n var years = function years() {\n return new EasyD(this, 'year');\n };\n\n var hours = function hours() {\n return new EasyD(this, 'hour');\n };\n\n // $FlowFixMe\n Number.prototype.day = days;\n // $FlowFixMe\n Number.prototype.days = days;\n // $FlowFixMe\n Number.prototype.month = months;\n // $FlowFixMe\n Number.prototype.months = months;\n // $FlowFixMe\n Number.prototype.years = years;\n // $FlowFixMe\n Number.prototype.year = years;\n // $FlowFixMe\n Number.prototype.hours = hours;\n // $FlowFixMe\n Number.prototype.hour = hours;\n\n // $FlowFixMe\n Object.assign(Date, {\n today: function today(mask) {\n return EasyDate.today(mask);\n },\n yesterday: function yesterday(mask) {\n return EasyDate.yesterday(mask);\n },\n tomorrow: function tomorrow(mask) {\n return EasyDate.tomorrow(mask);\n },\n tommorrow: function tommorrow(mask) {\n return EasyDate.tomorrow(mask);\n }\n });\n}\n\nexports.EasyDate = EasyDate;\nexports.easyDate = easyDate;\nexports.backwardCompatibility = backwardCompatibility;\n\n//# sourceURL=webpack:///./src/easy-date.js?"); | ||
@@ -134,0 +134,0 @@ /***/ }), |
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){var e=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,t=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,n=/[^-+\dA-Z]/g,o=function(e,t){for(e=String(e),t=t||2;e.length<t;)e="0"+e;return e};return function(u,a,i){var s=r;if(1!==arguments.length||"[object String]"!==Object.prototype.toString.call(u)||/\d/.test(u)||(a=u,u=void 0),u=u?new Date(u):new Date,isNaN(u))throw SyntaxError("invalid date");"UTC:"===(a=String(s.masks[a]||a||s.masks.default)).slice(0,4)&&(a=a.slice(4),i=!0);var c=i?"getUTC":"get",f=u[c+"Date"](),y=u[c+"Day"](),l=u[c+"Month"](),d=u[c+"FullYear"](),m=u[c+"Hours"](),p=u[c+"Minutes"](),h=u[c+"Seconds"](),b=u[c+"Milliseconds"](),v=i?0:u.getTimezoneOffset(),M={d:f,dd:o(f),ddd:s.i18n.dayNames[y],dddd:s.i18n.dayNames[y+7],m:l+1,mm:o(l+1),mmm:s.i18n.monthNames[l],mmmm:s.i18n.monthNames[l+12],yy:String(d).slice(2),yyyy:d,h:m%12||12,hh:o(m%12||12),H:m,HH:o(m),M:p,MM:o(p),s:h,ss:o(h),l:o(b,3),L:o(b>99?Math.round(b/10):b),t:m<12?"a":"p",tt:m<12?"am":"pm",T:m<12?"A":"P",TT:m<12?"AM":"PM",Z:i?"UTC":(String(u).match(t)||[""]).pop().replace(n,""),o:(v>0?"-":"+")+o(100*Math.floor(Math.abs(v)/60)+Math.abs(v)%60,4),S:["th","st","nd","rd"][f%10>3?0:(f%100-f%10!=10)*f%10]};return a.replace(e,function(e){return e in M?M[e]:e.slice(1,e.length-1)})}}();r.masks={default:"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"},r.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]},void 0===Date.prototype.format&&(Date.prototype.format=function(e,t){return r(this,e,t)}),t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.backwardCompatibility=t.easyDate=t.EasyDate=void 0;var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(e){return e&&e.__esModule?e:{default:e}}(n(0));function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function(e){function t(){return u(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,Date),r(t,null,[{key:"formatDate",value:function(e,t){return t?(0,o.default)(e,t):e}},{key:"today",value:function(e){return t.formatDate(new Date,e)}},{key:"yesterday",value:function(e){return new i(1,"day").ago(e)}},{key:"tomorrow",value:function(e){return new i(1,"day").fromNow(e)}}]),t}(),i=function(){function e(t,n){u(this,e),s.call(this),this.value=parseInt(t),this.conversionType=n}return r(e,[{key:"fromNow",value:function(e){var t=this.process(e);return t?t.fromNow():"Processor not found."}},{key:"ago",value:function(e){var t=this.process(e);return t?t.ago():"Processor not found."}},{key:"since",value:function(e,t){return this.now=new Date(e.valueOf()),this.fromNow(t)}},{key:"until",value:function(e,t){return this.now=new Date(e.valueOf()),this.ago(t)}},{key:"before",value:function(e,t){return this.until(e,t)}},{key:"toString",value:function(){return this.value+" "+this.conversionType+(this.value>1?"s":"")}},{key:"process",value:function(e){var t=this.conversionType,n=this.timeProcessor,r=this.now||new Date;return{hour:function(){return n(r,r.setHours,r.getHours,e)},day:function(){return n(r,r.setDate,r.getDate,e)},week:function(){return null},month:function(){return n(r,r.setMonth,r.getMonth,e)},year:function(){return n(r,r.setFullYear,r.getFullYear,e)}}[t]()}}]),e}(),s=function(){var e=this;this.timeProcessor=function(t,n,r,o){var u=e.value;return{ago:function(){return n.call(t,r.call(t)-u),a.formatDate(t,o)},fromNow:function(){return n.call(t,r.call(t)+u),a.formatDate(t,o)}}}};t.EasyDate=a,t.easyDate=function(e){var t=function(){return new i(e,"day")},n=function(){return new i(e,"month")},r=function(){return new i(e,"year")},o=function(){return new i(e,"hour")};return{hour:o,hours:o,day:t,days:t,month:n,months:n,year:r,years:r}},t.backwardCompatibility=function(){var e=function(){return new i(this,"day")},t=function(){return new i(this,"month")},n=function(){return new i(this,"year")},r=function(){return new i(this,"hour")};Number.prototype.day=e,Number.prototype.days=e,Number.prototype.month=t,Number.prototype.months=t,Number.prototype.years=n,Number.prototype.year=n,Number.prototype.hours=r,Number.prototype.hour=r,Object.assign(Date,{today:function(e){return a.today(e)},yesterday:function(e){return a.yesterday(e)},tomorrow:function(e){return a.tomorrow(e)},tommorrow:function(e){return a.tomorrow(e)}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1);Object.keys(r).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})});var o=n(0);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,t,n){e.exports=n(2)}])}); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){var e=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,t=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,n=/[^-+\dA-Z]/g,o=function(e,t){for(e=String(e),t=t||2;e.length<t;)e="0"+e;return e};return function(u,a,i){var s=r;if(1!==arguments.length||"[object String]"!==Object.prototype.toString.call(u)||/\d/.test(u)||(a=u,u=void 0),u=u?new Date(u):new Date,isNaN(u))throw SyntaxError("invalid date");"UTC:"===(a=String(s.masks[a]||a||s.masks.default)).slice(0,4)&&(a=a.slice(4),i=!0);var c=i?"getUTC":"get",y=u[c+"Date"](),f=u[c+"Day"](),l=u[c+"Month"](),d=u[c+"FullYear"](),m=u[c+"Hours"](),h=u[c+"Minutes"](),p=u[c+"Seconds"](),v=u[c+"Milliseconds"](),b=i?0:u.getTimezoneOffset(),M={d:y,dd:o(y),ddd:s.i18n.dayNames[f],dddd:s.i18n.dayNames[f+7],m:l+1,mm:o(l+1),mmm:s.i18n.monthNames[l],mmmm:s.i18n.monthNames[l+12],yy:String(d).slice(2),yyyy:d,h:m%12||12,hh:o(m%12||12),H:m,HH:o(m),M:h,MM:o(h),s:p,ss:o(p),l:o(v,3),L:o(v>99?Math.round(v/10):v),t:m<12?"a":"p",tt:m<12?"am":"pm",T:m<12?"A":"P",TT:m<12?"AM":"PM",Z:i?"UTC":(String(u).match(t)||[""]).pop().replace(n,""),o:(b>0?"-":"+")+o(100*Math.floor(Math.abs(b)/60)+Math.abs(b)%60,4),S:["th","st","nd","rd"][y%10>3?0:(y%100-y%10!=10)*y%10]};return a.replace(e,function(e){return e in M?M[e]:e.slice(1,e.length-1)})}}();r.masks={default:"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"},r.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]},void 0===Date.prototype.format&&(Date.prototype.format=function(e,t){return r(this,e,t)}),t.default=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.backwardCompatibility=t.easyDate=t.EasyDate=void 0;var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),o=function(e){return e&&e.__esModule?e:{default:e}}(n(0));function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var a=function(){function e(t){u(this,e),this._date=t}return r(e,[{key:"getDate",value:function(){return this._date}},{key:"format",value:function(e){return(0,o.default)(this._date,e)}}],[{key:"formatDate",value:function(e,t){return t?(0,o.default)(e,t):e}},{key:"today",value:function(t){return e.formatDate(new Date,t)}},{key:"yesterday",value:function(e){return new i(1,"day").ago(e)}},{key:"tomorrow",value:function(e){return new i(1,"day").fromNow(e)}}]),e}(),i=function(){function e(t,n){u(this,e),s.call(this),this.value=parseInt(t),this.conversionType=n}return r(e,[{key:"fromNow",value:function(e){var t=this.process(e);return t?t.fromNow():"Processor not found."}},{key:"ago",value:function(e){var t=this.process(e);return t?t.ago():"Processor not found."}},{key:"since",value:function(e,t){return this.now=new Date(e.valueOf()),this.fromNow(t)}},{key:"until",value:function(e,t){return this.now=new Date(e.valueOf()),this.ago(t)}},{key:"before",value:function(e,t){return this.until(e,t)}},{key:"toString",value:function(){return this.value+" "+this.conversionType+(this.value>1?"s":"")}},{key:"process",value:function(e){var t=this.conversionType,n=this.timeProcessor,r=this.now||new Date;return{hour:function(){return n(r,r.setHours,r.getHours,e)},day:function(){return n(r,r.setDate,r.getDate,e)},week:function(){return null},month:function(){return n(r,r.setMonth,r.getMonth,e)},year:function(){return n(r,r.setFullYear,r.getFullYear,e)}}[t]()}}]),e}(),s=function(){var e=this;this.timeProcessor=function(t,n,r,o){var u=e.value;return{ago:function(){return n.call(t,r.call(t)-u),a.formatDate(t,o)},fromNow:function(){return n.call(t,r.call(t)+u),a.formatDate(t,o)}}}};t.EasyDate=a,t.easyDate=function(e){var t=function(){return new i(e,"day")},n=function(){return new i(e,"month")},r=function(){return new i(e,"year")},o=function(){return new i(e,"hour")};return{hour:o,hours:o,day:t,days:t,month:n,months:n,year:r,years:r}},t.backwardCompatibility=function(){var e=function(){return new i(this,"day")},t=function(){return new i(this,"month")},n=function(){return new i(this,"year")},r=function(){return new i(this,"hour")};Number.prototype.day=e,Number.prototype.days=e,Number.prototype.month=t,Number.prototype.months=t,Number.prototype.years=n,Number.prototype.year=n,Number.prototype.hours=r,Number.prototype.hour=r,Object.assign(Date,{today:function(e){return a.today(e)},yesterday:function(e){return a.yesterday(e)},tomorrow:function(e){return a.tomorrow(e)},tommorrow:function(e){return a.tomorrow(e)}})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1);Object.keys(r).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return r[e]}})});var o=n(0);Object.keys(o).forEach(function(e){"default"!==e&&"__esModule"!==e&&Object.defineProperty(t,e,{enumerable:!0,get:function(){return o[e]}})})},function(e,t,n){e.exports=n(2)}])}); |
@@ -5,3 +5,3 @@ { | ||
"description": "EasyDate is a Javascript extension for easy dates manipulations which is heavily inspired by Rails ActiveSupport::Duration class.", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"keywords": [ | ||
@@ -8,0 +8,0 @@ "EasyDate", |
@@ -11,4 +11,17 @@ // @flow | ||
class EasyDate extends Date { | ||
class EasyDate { | ||
_date: Date | ||
constructor(date: Date) { | ||
this._date = date | ||
} | ||
getDate() { | ||
return this._date | ||
} | ||
format(mask: string) { | ||
return dateFormat(this._date, mask) | ||
} | ||
static formatDate(date: Date, mask?: string): Date | string { | ||
@@ -15,0 +28,0 @@ if (!!mask) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1280
87748