karl-common-util
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -18,8 +18,8 @@ "use strict"; | ||
year = undefined.getFullYear() + year; | ||
month = undefined.getMonth() + month; | ||
day = undefined.getDate() + day; | ||
hour = undefined.getHours() + hour; | ||
minute = undefined.getMinutes() + minute; | ||
second = undefined.getSeconds() + second; | ||
year = this.getFullYear() + year; | ||
month = this.getMonth() + month; | ||
day = this.getDate() + day; | ||
hour = this.getHours() + hour; | ||
minute = this.getMinutes() + minute; | ||
second = this.getSeconds() + second; | ||
var newDate = new Date(year, month, day, hour, minute, second); | ||
@@ -31,5 +31,5 @@ return newDate; | ||
Date.prototype.toDateStr = function () { | ||
var year = undefined.getFullYear(); | ||
var month = (undefined.getMonth() + 1).toString().padStart(2, "0"); | ||
var day = undefined.getDate().toString().padStart(2, "0"); | ||
var year = this.getFullYear(); | ||
var month = (this.getMonth() + 1).toString().padStart(2, "0"); | ||
var day = this.getDate().toString().padStart(2, "0"); | ||
return year + "-" + month + "-" + day; | ||
@@ -40,8 +40,8 @@ }; | ||
Date.prototype.toDateTimeStr = function () { | ||
var year = undefined.getFullYear(); | ||
var month = (undefined.getMonth() + 1).toString().padStart(2, "0"); | ||
var day = undefined.getDate().toString().padStart(2, "0"); | ||
var hour = undefined.getHours(); | ||
var minute = undefined.getMinutes(); | ||
var second = undefined.getSeconds(); | ||
var year = this.getFullYear(); | ||
var month = (this.getMonth() + 1).toString().padStart(2, "0"); | ||
var day = this.getDate().toString().padStart(2, "0"); | ||
var hour = this.getHours(); | ||
var minute = this.getMinutes(); | ||
var second = this.getSeconds(); | ||
return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second; | ||
@@ -53,3 +53,3 @@ }; | ||
//能整除400,或者整除4但不能被100整除 | ||
var year = undefined.getFullYear(); | ||
var year = this.getFullYear(); | ||
return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0; | ||
@@ -62,4 +62,4 @@ }; | ||
var days = 30; | ||
var month = undefined.getMonth() + 1; | ||
var isLeapYear = undefined.getFullYear(); | ||
var month = this.getMonth() + 1; | ||
var isLeapYear = this.getFullYear(); | ||
switch (month) { | ||
@@ -66,0 +66,0 @@ case 1: |
{ | ||
"name": "karl-common-util", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "karl common lib for client and server", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
if (!Date.prototype.add) { | ||
Date.prototype.add = ({year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0}) => { | ||
Date.prototype.add = function ({year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0}) { | ||
year = this.getFullYear() + year | ||
@@ -14,3 +14,3 @@ month = this.getMonth() + month | ||
if (!Date.prototype.toDateStr) { | ||
Date.prototype.toDateStr = () => { | ||
Date.prototype.toDateStr = function () { | ||
let year = this.getFullYear() | ||
@@ -23,3 +23,3 @@ let month = (this.getMonth() + 1).toString().padStart(2, "0") | ||
if (!Date.prototype.toDateTimeStr) { | ||
Date.prototype.toDateTimeStr = () => { | ||
Date.prototype.toDateTimeStr = function () { | ||
let year = this.getFullYear() | ||
@@ -34,4 +34,4 @@ let month = (this.getMonth() + 1).toString().padStart(2, "0") | ||
} | ||
if(!Date.prototype.isLeapYear){ | ||
Date.prototype.isLeapYear = ()=>{ | ||
if (!Date.prototype.isLeapYear) { | ||
Date.prototype.isLeapYear = function () { | ||
//能整除400,或者整除4但不能被100整除 | ||
@@ -44,3 +44,3 @@ let year = this.getFullYear() | ||
if (!Date.prototype.getDaysOfMonth) { | ||
Date.prototype.getDaysOfMonth = ()=>{ | ||
Date.prototype.getDaysOfMonth = function () { | ||
let days = 30 | ||
@@ -47,0 +47,0 @@ let month = this.getMonth() + 1 |
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
42192