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

@kmdtmyk/midnight

v0.3.3

Published

A javascript library that deals with date only not datetime.

Downloads

23

Readme

Publish Test

Midnight

A javascript library that deals with date only not datetime.

Installation

npm install @kmdtmyk/midnight

Usage

This is a subclass of Date, but the time is always 00:00:00.

import Midnight from '@kmdtmyk/midnight'

const date = new Midnight(2017, 5 , 15) // => 2017/05/15 (month is 1-12 not 0-11)
date instanceof Date // => true
date.getHours() // => 0
date.getMinutes() // => 0
date.getSeconds() // => 0
date.getMilliseconds() // => 0

Methods added

const date = new Midnight(2017, 5 , 15)

date.day() // => 15
date.day(10) // => 2017/05/10

date.month() // => 5
date.month(8) // => 2017/08/15

date.year() // => 2017
date.year(2020) // => 2020/05/15

date.startOfMonth() // => 2017/05/01
date.endOfMonth() // => 2017/05/31

date.startOfYear() // => 2017/01/01
date.endOfYear() // => 2017/12/31

date.startOfDecade() // => 2010/01/01
date.endOfDecade() // => 2019/12/31

date.nextDay() // => 2017/05/16
date.nextDay(3) // => 2017/05/18

date.nextMonth() // => 2017/06/15
date.nextMonth(3) // => 2017/08/15

date.nextYear() // => 2018/05/15
date.nextYear(3) // => 2020/05/15

date.nextSunday() // => 2017/05/21
date.nextMonday() // => 2017/05/22
date.nexTuesday() // => 2017/05/16
date.nextWednesday() // => 2017/05/17
date.nextThursday() // => 2017/05/18
date.nextFriday() // => 2017/05/19
date.nextSaturday() // => 2017/05/20

date.isSunday() // => false
date.isMonday() // => true
date.isTuesday() // => false
date.isWednesday() // => false
date.isThursday() // => false
date.isFriday() // => false
date.isSaturday() // => false

date.isValid() // => true
const date = Midnight.parse('2017/05/10')
// => 2017/05/10 not 1494342000000

Immutable

These methods return new instance and don't change own state.

const date1 = new Midnight(2017, 5 , 15)
const date2 = date1.nextDay()
// => date1: 2017/05/15 not 2017/05/16
// => date2: 2017/05/16

License

MIT