Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

karl-common-util

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

karl-common-util - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

57

dist/date/index.js

@@ -45,4 +45,61 @@ "use strict";

return days;
},
/**
* 对日期对象增加一个具体的增量
* @param value 日期对象
* @param year 年增量,默认为0
* @param month 月增量,默认为0
* @param day 日增量,默认为0
* @param hour 时增量,默认为0
* @param minute 分增量,默认为0
* @param second 秒增量,默认为0
*/
add: function add(_ref) {
var value = _ref.value,
_ref$year = _ref.year,
year = _ref$year === undefined ? 0 : _ref$year,
_ref$month = _ref.month,
month = _ref$month === undefined ? 0 : _ref$month,
_ref$day = _ref.day,
day = _ref$day === undefined ? 0 : _ref$day,
_ref$hour = _ref.hour,
hour = _ref$hour === undefined ? 0 : _ref$hour,
_ref$minute = _ref.minute,
minute = _ref$minute === undefined ? 0 : _ref$minute,
_ref$second = _ref.second,
second = _ref$second === undefined ? 0 : _ref$second;
year = value.getFullYear() + year;
month = value.getMonth() + month;
day = value.getDate() + day;
hour = value.getHours() + hour;
minute = value.getMinutes() + minute;
second = value.getSeconds() + second;
var newDate = new Date(year, month, day, hour, minute, second);
return newDate;
},
/**
* 转化为yyyy-MM-dd格式
* @param d
*/
toYMDString: function toYMDString(d) {
var year = d.getFullYear();
var month = (d.getMonth() + 1).toString().padStart(2, "0");
var day = d.getDate().toString().padStart(2, "0");
return year + "-" + month + "-" + day;
},
/**
* 转化为yyyy-MM-dd hh:mm:ss格式
* @param d
*/
toYMDHMSString: function toYMDHMSString(d) {
var year = d.getFullYear();
var month = (d.getMonth() + 1).toString().padStart(2, "0");
var day = d.getDate().toString().padStart(2, "0");
var hour = d.getHours();
var minute = d.getMinutes();
var second = d.getSeconds();
return year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second;
}
};

2

package.json
{
"name": "karl-common-util",
"version": "1.0.2",
"version": "1.0.3",
"description": "karl common lib for client and server",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -40,4 +40,47 @@ export default {

return days
}
},
/**
* 对日期对象增加一个具体的增量
* @param value 日期对象
* @param year 年增量,默认为0
* @param month 月增量,默认为0
* @param day 日增量,默认为0
* @param hour 时增量,默认为0
* @param minute 分增量,默认为0
* @param second 秒增量,默认为0
*/
add: ({value, year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0}) => {
year = value.getFullYear() + year
month = value.getMonth() + month
day = value.getDate() + day
hour = value.getHours() + hour
minute = value.getMinutes() + minute
second = value.getSeconds() + second
let newDate = new Date(year, month, day, hour, minute, second)
return newDate
},
/**
* 转化为yyyy-MM-dd格式
* @param d
*/
toYMDString: d => {
let year = d.getFullYear()
let month = (d.getMonth() + 1).toString().padStart(2, "0")
let day = d.getDate().toString().padStart(2, "0")
return `${year}-${month}-${day}`
},
/**
* 转化为yyyy-MM-dd hh:mm:ss格式
* @param d
*/
toYMDHMSString: d => {
let year = d.getFullYear()
let month = (d.getMonth() + 1).toString().padStart(2, "0")
let day = d.getDate().toString().padStart(2, "0")
let hour = d.getHours()
let minute = d.getMinutes()
let second = d.getSeconds()
return `${year}-${month}-${day} ${hour}:${minute}:${second}`
},
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc