New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@basichelpers/date

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@basichelpers/date - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

index.js

63

index.ts

@@ -1,35 +0,34 @@

export default class date {
/**
* @param {date} payload
* @param {string} format YYYY/MM/DD hh:mm:ss:SSS
* @returns {string}
*/
dateFormat (payload: Date, format: string = 'YYYY/MM/DD') {
format = format.replace(/YYYY/g, payload.getFullYear().toString())
format = format.replace(/MM/g, ('0' + (payload.getMonth() + 1)).slice(-2))
format = format.replace(/DD/g, ('0' + payload.getDate()).slice(-2))
format = format.replace(/hh/g, ('0' + payload.getHours()).slice(-2))
format = format.replace(/mm/g, ('0' + payload.getMinutes()).slice(-2))
format = format.replace(/ss/g, ('0' + payload.getSeconds()).slice(-2))
format = format.replace(
/SSS/g,
('00' + payload.getMilliseconds()).slice(-3)
)
return format
}
/**
* @param {date} payload
* @param {string} format YYYY/MM/DD hh:mm:ss:SSS
* @returns {string}
*/
export function dateFormat (payload: Date, format: string = 'YYYY/MM/DD') {
format = format.replace(/YYYY/g, payload.getFullYear().toString())
format = format.replace(/MM/g, ('0' + (payload.getMonth() + 1)).slice(-2))
format = format.replace(/DD/g, ('0' + payload.getDate()).slice(-2))
format = format.replace(/hh/g, ('0' + payload.getHours()).slice(-2))
format = format.replace(/mm/g, ('0' + payload.getMinutes()).slice(-2))
format = format.replace(/ss/g, ('0' + payload.getSeconds()).slice(-2))
format = format.replace(/SSS/g, ('00' + payload.getMilliseconds()).slice(-3))
return format
}
/**
* @param {string} payload 2021/12/31
* @param {string} format
* @param {string} time 12:00
* @returns {date}
*/
stringtoDate (date: string, st: string, time: string = ''): Date {
const will: any = new RegExp(st, 'g')
let willdate = date.replace(will, '/')
if (time) {
willdate = willdate + ' ' + time + ':00'
}
return new Date(willdate)
/**
* @param {string} payload 2021/12/31
* @param {string} format
* @param {string} time 12:00
* @returns {date}
*/
export function stringtoDate (
date: string,
st: string,
time: string = ''
): Date {
const will: any = new RegExp(st, 'g')
let willdate = date.replace(will, '/')
if (time) {
willdate = willdate + ' ' + time + ':00'
}
return new Date(willdate)
}
{
"name": "@basichelpers/date",
"version": "0.0.1",
"version": "0.0.2",
"description": "```bash import { dateFormat, stringtoDate } from '@basichelpers/date'",
"main": "index.ts",
"main": "dist/index.js",
"scripts": {

@@ -10,7 +10,10 @@ "test": "echo \"Error: no test specified\" && exit 1",

},
"author": "",
"author": "91nakashima",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"dependencies": {
"typescript": "^4.5.4"
}
}
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