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-enhanced

v1.0.1

Published

DateEnhanced class extends javascript Date class to add some convenience methods.

Downloads

12

Readme

This document is work in progress, not yet completed

date-enhanced

Smarter Date class than the default javascript Date

Introduction

DateEnhanced extends Date class by adding several convenience methods, both static and instance.

Compatibility

This module uses ES6 syntax including spread operator. Therefore it will run in NodeJS version 6 and above.

Installation

npm install date-enhanced

How to Use

const DateEnhanced = require('date-enhanced');

Use the same way you would use Date.

Static Methods

DateEnhanced.today()

Returns DateEnhanced object set to current local date, 00:00:00 local time. Since version 1.

DateEnhanced.yesterday()

Returns DateEnhanced object set to current local date minus one day, 00:00:00 local time. Since version 1.

DateEnhanced.tomorrow()

Returns DateEnhanced object set to current local date plus one day, 00:00:00 local time. Since version 1.

DateEnhanced.thisMonth()

Returns DateEnhanced object set to the first day of the current month, 00:00:00 local time. Since version 1.

DateEnhanced.nextMonth()

Returns DateEnhanced object set to the first day of the next month, 00:00:00 local time. Since version 1.

Instance Methods

truncate( precision = 'DD' )

Truncates instance value to the units indicated in parameter precision and returns the original instance, i.e. it is a chainable method. Precision units are:

  • 'ss' or 'second' Truncates to seconds, i.e. set milliseconds to zero.
  • 'mm' or 'minute' Truncates to minute, set seconds and milliseconds to zero.
  • 'hh' or 'hour' Truncates to hour, set minutes, seconds and milliseconds to zero.
  • 'DD' or 'day' Truncates to day, i.e. set local time to zero.
  • 'MM' or 'month' Truncates to month, i.e. sets local time to zero and day of month to 1
  • 'YYYY' or 'year' Truncates to the first day of the year, local time 00:00:00.000

Please note that this method modifies the instance itself.

truncated( precision = 'DD' )

This method does the same job as truncate() except that it returns a new, truncated instance and leaves the original instance unmodified.

addSeconds ( seconds )

Returns a new instance with value changed by the amount of seconds specified (both positive or negative).

addMinutes ( minutes )

Returns a new instance with value changed by the amount of minutes specified (both positive or negative).

addHours ( hours )

Returns a new instance with value changed by the amount of hours specified (both positive or negative).

addDays ( days )

Returns a new instance with value changed by the amount of days specified (both positive or negative).

addMonths ( months )

Returns a new instance with value changed by the amount of months specified (both positive or negative).

addYears ( years )

Returns a new instance with value changed by the amount of years specified (both positive or negative).