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

betterdate

v0.0.5

Published

A 'BetterDate' is essentially a 'Date' that is easier and more intuitive to use than the built-in 'Date' class.

Downloads

9

Readme

BetterDate

BetterDate is a JavaScript class just like the built-in Date, except:

  • Numeric month values are one-indexed like year and date (there is no year, month, or day zero), instead of zero-indexed.
  • Values can be modified with relative values using add* functions, instead of being absolute requiring both a set* and get* to be called to modify by a delta.
  • The time zone offset is modifiable, instead of being unmodifiable without modifying the interpretor's environment.
  • The time zone name is accessible as a separate property and is modifiable, instead of being, inaccessible and unmodifiable without modifying the interpretor's environment.
  • Week of the year information is accessible (as a fractional week, Math.floor the result for whole weeks or Math.ceil the result for ordinal/partial weeks).
  • Leap year information is available on instances for the year represented and on the class for any year in question.
  • Day of the week is still zero-indexed.
let betterDate = new BetterDate();

The '1' is one-indexed to intuitively mean 'January', not zero-indexed to mean 'February'.

betterDate = new BetterDate( 2017, 1, 26 );
new Date( betterDate );
// Thu Jan 26 2017 00:00:00 GMT-0600 (Central Standard Time)

Remove 10 hours from a 'BetterDate':

let epoch_ms = betterDate.addHours( -10 );
// 1485374400000
betterDate.toString();
// Wed Jan 25 2017 14:00:00 GMT-0600 (Central Standard Time)

Change the time zone offset (and name) without affecting the represented time.

betterDate.setTimezoneOffset( 480 );
betterDate.setTimezoneName( 'America/Los_Angeles' );
betterDate.toString();
// Wed Jan 25 2017 12:00:00 GMT-0800 (America/Los_Angeles)
new Date( betterDate );
// Wed Jan 25 2017 14:00:00 GMT-0600 (Central Standard Time)

Get week of year.

Math.ceil( betterDate.getWeeksOfYear());
// 4