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

date-calc

v1.0.9

Published

a simple date calculator for javascript

Downloads

15

Readme

NPM version Build Status

Simple Date Calculator: DateCalc

A simple date calculator from my personal project Zhihu-Spider

NPM

DateCalc

Test

Test Framework is ava

npm install
npm test

update

@v1.0.6

add the time(timestamp) function that returns full date

@v1.0.6

add the beforeCN and afterCN function that returns chinese format days

@v1.0.5

fix bug of monthEN() function

@v1.0.4

add the today function

const DateCalc = require('date-calc')
const d = new DateCalc()

d.today() // returns today date

@v1.0.3

fix the new Date() bug of Safari of macOS and iOS

@v1.0.2

  1. update: method now()

The now() can receive a parameter like now(20161001)

const DateCalc = require('date-calc')
let d = new DateCalc();
console.log(d.now()) // returns now date
d.now('20161002')  // changs DateCalc's inner data
console.log(d.now()) // returns 20161002
console.log(d.before()) // returns 20161001
console.log(d.after(10)) // returns 20161012
  1. add: method weekDay()

The weekDay() returns an Object of weekdays info

const DateCalc = require('date-calc')
let d = new DateCalc('20161001');
d.weekDay() // returns { day: 6, en: 'Sat', cn: '六' }

Usage

const DateCalc = require('date-calc')
// or ES2015
// import DateCalc from 'date-calc'

let d = new DateCalc('20460818');
d.before();
d.after();
d.before(2);
d.after(2);
d.now();
d.month();
d.beforeMonth()
d.afterMonth()

Parameters

  • new DateCalc() no parameters means today
  • new DateCalc('20460818') reference date

Instance Method

  • d.before() the day before reference date 20460817
  • d.after() the day after reference date 20460819
  • d.before(2) twos days before reference date 忽略初始天数 20460816
  • d.after(2) twos days after reference date 20460820
  • d.now() now date 20460818
  • d.month() the month of reference date 204608
  • d.beforeMonth() the month before reference date 204607
  • d.afterMonth() the month after reference date 204609
  • month English descripe
    • new DateCalc('20460118').monthEN() returns 'Jan'
    • new DateCalc('20460218').monthEN() returns 'Feb'
    • new DateCalc('20460318').monthEN() returns 'Mar'
    • new DateCalc('20460418').monthEN() returns 'Apr'
    • new DateCalc('20460518').monthEN() returns 'May'
    • new DateCalc('20460618').monthEN() returns 'Jun'
    • new DateCalc('20460718').monthEN() returns 'Jul'
    • new DateCalc('20460818').monthEN() returns 'Aug'
    • new DateCalc('20460918').monthEN() returns 'Sep'
    • new DateCalc('20461018').monthEN() returns 'Oct'
    • new DateCalc('20461118').monthEN() returns 'Nov'
    • new DateCalc('20461218').monthEN() returns 'Dec'
  • month Chinese descripe
    new DateCalc('20460118').CHN() returns '2046年01月18日'