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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ucar-date

v0.1.1

Published

ucar uitl for Date

Readme

ucar-date

Npm Staus Build Status Coverage Status

神州优车Date工具集合

Usage

import UcarDate from 'ucar-date'
	
let u = new UcarDate(date:String/Number/Date)

ucarDate 可以接受String类型参数 yyyy-MM-dd/yyyy/MM/dd 初始化指定日期

Property

# 传入或默认的时间值:Date
u.value
	
# 时间戳:Number
u.timestamp
	
# 年:Number
u.year
	
# 月:Number
u.month
	
# 月中的第几日:Number
u.date

# 当日属于本月的第几周:Number
u.noWeekOfMonth
	
# 周几:Number
u.day
	
# 是否是闰年:Boolean
u.isLeapYear
	
# 是否是较长月份:Boolean
u.isLongMonth
	
# 当月1号周几:Number
u.offsetOfLastMonth

# 当周的周日:Date
u.firstDayOfWeek

# 当月的1号:Date
u.firstDayOfMonth

# 当年的1月1号:Date
u.firstDayOfYear

# 当日的格式化后的字符串:String
u.dateStr 格式:yyyy-MM-dd

API

#获取格式化后的日期字符串:String(format:String)
u.getDateStr() 默认格式:yyyy-MM-dd
#ps: format格式: yyyy$MM$dd 
	 $可以是任意单个字符, yMd不可变

#获取这周所有的日期实例:Array	
u.getAllOfWeek()
	
#获取这个月有多少天:Number
u.getDaysOfMonth()

#获取这个月所有的日期实例:Array
u.getAllOfMonth()
	
#获取这一年应该有多少天:Number
u.getDaysOfYear()

#获取这一年所有的日期实例:Array
u.getAllOfYear()
	
#获取这个月有多少周(按照首日非周日则并入上月计算):Number
u.getWeeksOfMonth()
	
#获取前一天:UcarDate
u.preDay()
	
#获取后一天:UcarDate
u.nextDay()

#获取上一周所有的日期实例:Array
u.getAllOfPreWeek()

#获取下一周所有的日期实例:Array
u.getAllOfNextWeek()

#获取上个月所有的日期实例:Array
u.getAllOfPreMonth()

#获取下个月所有的日期实例:Array
u.getAllOfNextMonth()

#获取上一年所有的日期实例:Array
u.getAllOfPreYear()

#获取下一年所有的日期实例:Array
u.getAllOfNextYear()

#获取与指定时间之间的偏移量:Number(date:Date/String/Number/UcarDate)
u.getOffsetOfDate()
#eg:
	u.getOffsetOfDate('2016-08-21') 
	/* -184 */ /* u当前日期为0往前数的第184天 */

#获取指定范围内的所有日期实例:Array(date:Date/String/Number, range:Number, reverse(!required):Boolean)
u.getAllOfRange()
#eg: 
	u.getAllOfRange('2014-04-17', 2)
	/* [{..., date: 17},{..., date: 18}] */
	
	u.getAllOfRange('2014-04-17', 2, true)
	/* [{..., date: 16},{..., date: 17}] */