New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

date-cipher

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-cipher

二次封装的时间计算快捷函数使用库

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

date-cipher

NPM version Build Status GitHub forks GitHub stars NPM download GitHub license

二次封装的时间计算快捷函数使用库

methods

简单的格式化日期格式

/**
 * @method formatDate 简单的格式化日期格式
 *
 * @param {Date} date 需要被格式化的日期
 * @param {String} formatStr 格式化字符串
 *
 * @return {String} 返回格式化好的日期
 */

使用方式 =>

import { formatDate } from 'date-cipher'

console.log(formatDate())

计算周的起止时间

/**
 * @method s2eWeek 计算周的起止时间
 *
 * @param {Date} date 任意一天
 * @param {String} formatStr 格式化字符串
 * @param {Boolean} isCurrent 结束时间为当前时间
 *
 * @return {Object} 返回起止日期
 */

使用方式 =>

import { s2eWeek } from 'date-cipher'

console.log(s2eWeek())

计算月的起止时间

/**
 * @method s2eMonth 计算月的起止时间
 *
 * @param {Date} date 任意一天
 * @param {String} formatStr 格式化字符串
 * @param {Boolean} isCurrent 结束时间为当前时间
 *
 * @return {Object} 返回起止日期
 */

使用方式 =>

import { s2eMonth } from 'date-cipher'

console.log(s2eMonth())

计算年的起止时间

/**
 * @method s2eYear 计算年的起止时间
 *
 * @param {Date} date 任意一天
 * @param {String} formatStr 格式化字符串
 * @param {Boolean} isCurrent 结束时间为当前时间
 *
 * @return {Object} 返回起止日期
 */

使用方式 =>

import { s2eYear } from 'date-cipher'

console.log(s2eYear())

计算N天前或者N天后的日期

/**
 * @method dayByDays 计算N天前或者N天后的日期
 *
 * @param {Date} date 一年中任意一天
 * @param {String} formatStr 格式化字符串
 * @param {Number} days 计算天数
 * @param {String} type 计算的是之前的日期 before 之后的日期 after
 *
 * @return {Object} 默认返回昨天日期
 */

使用方式 =>

import { dayByDays } from 'date-cipher'

console.log(dayByDays())

计算N天前或者N天后的日期(起止日期)

/**
 * @method s2eDayByDays 计算N天前或者N天后的日期(起止日期)
 *
 * @param {String} formatStr 格式化字符串
 * @param {Number} days 计算天数
 * @param {String} type 计算的是之前的日期 before 之后的日期 after
 * @param {Boolean} isCurrent 是否包含今天
 *
 * @return {Object} 默认返回最近一周的起止日期
 */

使用方式 =>

import { s2eDayByDays } from 'date-cipher'

console.log(s2eDayByDays())

计算两个时间段的相差天数, 精确到 N 年 N 天 精确到小数后两位

/**
 * @method diffDays 计算两个时间段的相差天数,精确到 N 年 N 天 精确到小数后两位
 *
 * @param {Date} startDate 开始时间
 * @param {Date} endDate 结束时间
 * @param {Boolean} format 是否进行格式化,为 true 格式化成 N 年 N 天,为 false 直接返回未格式化的
 *
 * @return {String} 相差的天数
 */

使用方式 =>

import { diffDays } from 'date-cipher'

console.log(diffDays())

Keywords

node

FAQs

Package last updated on 23 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts