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

dubium

v0.0.16

Published

Light Javascript date and time utilities (formatting, ranges e.t.c)

Downloads

26

Readme

If you appreciate this project, please 🌟 it on GitHub.

Dubium works both in the browser and with node.

For browser use, either host the dubium.js file yourself (By downloading the current release here) or use a CDN (and, yes, it's free):

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dubium.min.js"></script>

As for NodeJS, it can be included like so:

const dubium = require("dubium");

Example

// In this example, if the date is not passed in, we'll pretend it's currently
// Febuary 1, 1970 19:30:00 UTC.

// .format returns the current date and/or time in a formatted manor
dubium.format("DD/MM/YYYY hh:mm:ss") // 01/02/1970 19:30:00
dubium.format("MM/DD/YYYY H:mm:ss a") // 02/01/1970 7:30:00 pm
dubium.format("DD/MMM/YY H:mm:ss A") // 01/Mar/70 7:30:00 PM
dubium.format("DD/MMMM/YY H:mm:ss A") // 01/March/70 7:30:00 PM

// You can also pass in a date to format:
dubium.format("DD/MM/YYYY hh:mm:ss", 1554159037369); // 01/04/2019 23:50:37
dubium.format("DD/MM/YYYY hh:mm:ss", "Fri, 02 Feb 1996 03:04:05 GMT"); // 02/02/1996 03:04:05

// You may unformat a string to get the epoch integer:
dubium.unformat("01/March/70 7:30:00 PM", "DD/MMMM/YY H:mm:ss A"); // 3163604400000

// You can get all the day value from a range of dates (inclusive of the ones being passed in)...
dubium.daysInRange(1554160761053, 1554333561053) // Array(3) [ 1554160761053, 1554247161053, 1554333561053 ]

// You can also get the range of the start of the week and end
dubium.getWeekRange() //Array [ 1554073200000, 1554677999999 ]
// Obviously you can pass an epoch value, too, if you want:
dubium.getWeekRange(3163604400000); // Array [ 3163446000000, 3161375999999 ]

// And, yeah, that's pretty much it... 
// These functions will be improved and added upon soon, too.

Benchmarks

Tested the speed of formatting and unformatting in Chrome 75 on Windows 10.

See it for yourself here on jsPerf.

|Library|Ops/sec| |--|--| |Dubium|197,278| |DayJS|108,859| |MomentJS|56,163|

Development

Building dubium for browser:

npm run build