npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@zhouhua5982/date-utils

v1.0.10

Published

日期处理工具:主要功能为获取起止日期

Downloads

9

Readme

date-utils(日期处理工具)

日期处理工具:主要功能为获取起止日期

Features(功能)

  1. 获取当前日期
  2. 获取本周的起止日期
  3. 获取本月的起止日期
  4. 获取本季度开始的月份
  5. 获得指定月份的天数
  6. 获得本季度的起止日期
  7. 得到本年的起止日期
  8. 返回上一个月的第一天
  9. 获得上一月的起止日期
  10. 获得上一周的起止日期
  11. 得到上季度的第一天
  12. 得到上季度的起止日期
  13. 得到去年的起止日期

install(安装)

// npm
npm install @zhouhua5982/date-utils

// script
<script src="/node_modules/@zhouhua5982/date-utils/dist/date-utils.min.js"></script>

Usage(使用方法)

// commonjs
const dateUtils = require('@zhouhua5982/date-utils')
// 获取当前日期
const currentDate = dateUtils.getCurrentDate()
// 获取本周的起止时间
const currentWeek = dateUtils.getCurrentWeek()

// es
// 获取当前日期
import { getCurrentDate } from '@zhouhua5982/date-utils'
const currentDate = getCurrentDate()

// 获取本周的起止时间
import { getCurrentWeek } from '@zhouhua5982/date-utils'
const currentWeek = getCurrentWeek()
// return: Array(2)

// 获取本月的起止时间
import { getCurrentMonth } from '@zhouhua5982/date-utils'
const currentMonth = getCurrentMonth()
// return: Array(2)

// 获取本季度开始的月份
import { getQuarterSeasonStartMonth } from '@zhouhua5982/date-utils'
const month = 5 // 5月份
const quarterSeasonStartMonth = getQuarterSeasonStartMonth(month)
// return: 0->春季   3->夏季   6->秋季   9->冬季

// 获得指定月份的天数
import { getMonthDays } from '@zhouhua5982/date-utils'
const year = 2020
const month = 9
const monthDays = getMonthDays(2020, 9)
// return: monthDays = 30

// 获得本季度的起止日期
import { getCurrentSeason } from '@zhouhua5982/date-utils'
const currentSeason = getCurrentSeason()
// return: Array(2)

// 得到本年的起止日期
import { getCurrentSeason } from '@zhouhua5982/date-utils'
const currentYear = getCurrentSeason()
// return: Array(2)

// 返回上一个月的第一天Date类型
import { getPriorMonthFirstDay } from '@zhouhua5982/date-utils'
const year = 2020
const month = 9
const priorMonthFirstDay = getPriorMonthFirstDay(year, month)
// return: Date()

// 获得上一月的起止日期
import { getPreviousMonth } from '@zhouhua5982/date-utils'
const previousMonth = getPreviousMonth()
// return: Array(2)

// 获得上一周的起止日期
import { getPreviousWeek } from '@zhouhua5982/date-utils'
const previousWeek = getPreviousWeek()
// return: Array(2)

// 得到上季度的第一天的 Date 类型
import { getPriorSeasonFirstDay } from '@zhouhua5982/date-utils'
const year = 2020
const month = 9
const priorSeasonFirstDay = getPriorSeasonFirstDay(year, month)

// 得到上季度的起止日期
import { getPreviousSeason } from '@zhouhua5982/date-utils'
const previousSeason = getPreviousSeason()
// return: Array(2)

// 得到去年的起止日期
import { getPreviousSeason } from '@zhouhua5982/date-utils'
const previousSeason = getPreviousSeason()
// return: Array(2)