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

zax-date

v2.0.5

Published

zax-date

Downloads

12

Readme

Zax Date

NPM version Build Status codecov code style: prettier

Date module

Browsers support

| IE / Edge | Firefox | Chrome | Safari | iOS Safari | Opera | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | IE8+ Edge+ | last 10 versions | last 10 versions | last 2 versions | last 2 versions | last 2 versions |

Install

npm i zax-date -S

build with rollup

npm run build

use

import { compare, offset, get, ago, format, diff, age, isLeapYear, CompareType, OffsetType, GetOffsetType, SetOffsetType } from 'zax-date'
import zaxDate from 'zax-date'

. compare

zaxDate.compare('2018/9/10', '2018/9/5')
zaxDate.compare('2018/9/10', '2018/9/10')
zaxDate.compare('2018/9/10', '2018/9/11')
zaxDate.compare('2018/9/10')
1
0
-1
-1

. offset

zaxDate.offset('2018/9/10 15:47:59', OffsetType.FULLYEAR, 2)
zaxDate.offset('2018/9/10 15:47:59', OffsetType.MONTH, 2)
zaxDate.offset('2018/9/10 15:47:59', OffsetType.DATE, 2)
zaxDate.offset('2018/9/10 15:47:59', OffsetType.HOURS, 2)
zaxDate.offset('2018/9/10 15:47:59', OffsetType.MINUTES, 2)
zaxDate.offset('2018/9/10 15:47:59', OffsetType.SECONDS, 2)
2020-09-10T07:47:59.000Z
2018-11-10T07:47:59.000Z
2018-09-12T07:47:59.000Z
2018-09-10T09:47:59.000Z
2018-09-10T07:49:59.000Z
2018-09-10T07:48:01.000Z

. get

zaxDate.get('2018/9/10 15:47:59', OffsetType.FULLYEAR)
zaxDate.get('2018/9/10 15:47:59', OffsetType.MONTH)
zaxDate.get('2018/9/10 15:47:59', OffsetType.DATE)
zaxDate.get('2018/9/10 15:47:59', OffsetType.HOURS)
zaxDate.get('2018/9/10 15:47:59', OffsetType.MINUTES)
zaxDate.get('2018/9/10 15:47:59', OffsetType.SECONDS)
2018
8
10
15
47
59

. ago

zaxDate.ago('2016/9/11','zh-cn')
zaxDate.ago('2018/8/11','zh-cn')
zaxDate.ago('2019/1/14','zh-cn')
zaxDate.ago('2019/1/15 15:47:59','zh-cn')
zaxDate.ago('2019/1/16 16:47:59','zh-cn')
zaxDate.ago('2019/06/16 16:48:59','zh-cn')
3年前
11个月前
6个月前
6个月前
6个月前
26天前

. format

zaxDate.format('2018/10/25', 'yyyy-mm-dd')
zaxDate.format('2018-10-25', 'yyyy/mm/dd HH:MM:SS')
zaxDate.format('2018/10/25 11:11:11.123', 'yyyy-mm-dd HH:MM:SS.SSS')
zaxDate.format(1547625501970, 'yyyy-mm-dd HH:MM:SS.SSS')
zaxDate.format('1547625501970', 'yyyy-mm-dd HH:MM:SS.SSS')
zaxDate.format(new Date(), 'yyyy/mm/dd HH:MM:SS.SSS')
zaxDate.format('2018/10/25 11:59:59', 'yyyy-mm-dd hh:MM:SS') // '-> am') //am
zaxDate.format('2018/10/25 13:00:01', 'yyyy-mm-dd hh:MM:SS') // '-> pm') //pm
zaxDate.format(new Date(), 'yyyy年mm月dd日HH点MM分SS秒SSS微秒')
2018-10-25
2018/10/25 00:00:00
2018-10-25 11:11:11.123
2019-01-16 15:58:21.970
2019-01-16 15:58:21.970
2019/07/12 22:04:55.814
2018-10-25 11:59:59 -> am
2018-10-25 01:00:01 -> pm
2019年07月12日22点04分55秒814微秒

. diff

zaxDate.diff('2018/10/27 15:47:59', '2018/10/26 11:37:35')
{ days: -2, hours: -5, minutes: -11, seconds: -24 }

. age

zaxDate.age('2018/10/25 11:59:59', true)
zaxDate.age('2017/10/25 11:59:59', true)
0
1

. isLeapYear

zaxDate.isLeapYear('2000/12/20')
zaxDate.isLeapYear('2010/12/20')
zaxDate.isLeapYear('1996/12/20')
false
false
true

Date and time patterns

  • yy = short year //废弃
  • yyyy = long year
  • m = month (1-12)
  • mm = month (01-12)
  • d = day (1 - 31)
  • dd = day (01 - 31)
  • h = hour in am/pm (0-12)
  • hh = hour in am/pm (00-12)
  • H = hour in day (0-23)
  • HH = hour in day (00-23)
  • M = minute in hour(0-59)
  • MM = minute in hour(01-59)
  • S = second in in minute(0-59)
  • SS = second in in minute(01-59)
  • SSS = milliseconds in in second(01-999)

More