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

fe-utils

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fe-utils - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

41

libs/date.js
const date = {
dateFormat: (d, fmt) => { // format(new Date(), 'MM月dd日 hh:mm')
dateFormat (d, fmt) { // format(new Date(), 'YYYY年MM月DD日 hh:mm:ss')
if (!d || !fmt) {
throw new Error('lack date or format')
}
if (typeof(d) === 'string') {
d = new Date(d)
}
const o = {
'M+': d.getMonth() + 1, // 月份
'd+': d.getDate(), // 日
'D+': d.getDate(), // 日
'h+': d.getHours(), // 小时
'm+': d.getMinutes(), // 分
's+': d.getSeconds(), // 秒
'q+': Math.floor((d.getMonth() + 3) / 3), // 季度
'Q+': Math.floor((d.getMonth() + 3) / 3), // 季度
'S': d.getMilliseconds() // 毫秒
}
if (/(y+)/.test(fmt)) {
if (/(Y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (d.getFullYear() + '').substr(4 - RegExp.$1.length))

@@ -25,4 +31,31 @@ }

}
// TodayFormat (date) {
// if (!date) {
// throw new Error('lack date')
// }
// const fmt = 'YYYY-MM-DD'
// const cur = new Date() // 当前年月日
// const curYear = cur.getFullYear()
// const curMonth = cur.getMonth() + 1
// const curDay = cur.getDate()
// const next = new Date(`${curYear}/${curMonth}/${curDay + 1}`) // 明天年月日
// const param = new Date(date) // 传进来的年月日
// const paramDay = new Date().getDate()
// const nowDate = this.dateFormat(cur, fmt)
// const nextDate = this.dateFormat(next, fmt)
// const paramDate = this.dateFormat(param, fmt)
// if (nowDate == nextDate) {
// return '今天' + this.dateFormat(paramDate, 'hh:mm')
// } else if (paramDay === curDay) {
// return '明天' + this.dateFormat(paramDate, 'hh:mm')
// } else {
// return this.dateFormat(paramDate, 'MM月DD日 hh:mm')
// }
// }
}
export default date

2

package.json
{
"name": "fe-utils",
"version": "1.0.6",
"version": "1.0.7",
"description": "",

@@ -5,0 +5,0 @@ "main": "fe-utils.js",

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