chaining-date
Advanced tools
Comparing version 0.2.2 to 0.3.1
@@ -1,1 +0,1 @@ | ||
var ChainingDate=function(){var t=Date;function n(n){this.date="number"==typeof n?new t(n):"string"==typeof n?new t(t.parse(n)):n||new t}var e=n.prototype;return e.add=function(){return this},e.set=function(){return this},e.get=function(){return this.date},e.toString=function(t){var n=this.date;return t?n:n.toString()},n}(); | ||
var ChainingDate=function(){var t={YYYY:"FullYear",MM:"Month",DD:"Date",D:"Day",hh:"Hours",mm:"Minutes",ss:"Seconds",sss:"Milliseconds"},n=Date;function e(t){this.date="number"==typeof t?new n(t):"string"==typeof t?new n(n.parse(t)):t||new n}var r=e.prototype;return r.add=function(){return this},r.set=function(n,e){return this.date["set"+t[n]](e),this},r.get=function(n,e){return this.date["get"+t[n]](e)},r.toString=function(t){var n=this.date;return t?n:n.toString()},e}(); |
/** | ||
* @author TroyTae | ||
* @version 0.2.2 | ||
* @version 0.3.1 | ||
* @name chaining-date | ||
@@ -8,2 +8,13 @@ */ | ||
var DateFormat = { | ||
YYYY: 'FullYear', | ||
MM: 'Month', | ||
DD: 'Date', | ||
D: 'Day', | ||
hh: 'Hours', | ||
mm: 'Minutes', | ||
ss: 'Seconds', | ||
sss: 'Milliseconds', | ||
}; | ||
var D = Date; | ||
@@ -22,7 +33,8 @@ function ChainingDate(date) { | ||
}; | ||
P.set = function () { | ||
P.set = function (format, value) { | ||
this.date['set' + DateFormat[format]](value); | ||
return this; | ||
}; | ||
P.get = function () { | ||
return this.date; | ||
P.get = function (format, value) { | ||
return this.date['get' + DateFormat[format]](value); | ||
}; | ||
@@ -29,0 +41,0 @@ P.toString = function (pattern) { |
{ | ||
"name": "chaining-date", | ||
"version": "0.2.2", | ||
"version": "0.3.1", | ||
"description": "A tiny module for using Date with chaining ⏱", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -16,7 +16,8 @@ import { DateFormat } from './constants'; | ||
}; | ||
P.set = function () { | ||
P.set = function (format, value) { | ||
this.date['set' + DateFormat[format]](value); | ||
return this; | ||
}; | ||
P.get = function () { | ||
return this.date; | ||
P.get = function (format, value) { | ||
return this.date['get' + DateFormat[format]](value); | ||
}; | ||
@@ -23,0 +24,0 @@ P.toString = function (pattern) { |
6005
114