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-util-generic

v1.1.0

Published

Date Util manages to transform the Date to readable format.

Downloads

5

Readme

Date Util for Date Tweaks

Date Util manages to transform the Date to readable format.

Install

npm i --save date-util-generic

or

yarn add date-util-generic

Examples

import  dateUtil  from  'date-util-generic'
dateUtil.evaluate("2019-9-15", { separator:  '-', today:  'false', format:  "dd-MMMM-YYYY"}) // Output : 15-September-2019
dateUtil.evaluate("2019-9-29", { separator:  '--', today:  'false', format:  "dd-MM-YYYY"}) // Output : 29--Sep--2019
dateUtil.evaluate("MM-YY-DD", { separator:  '-'}) // Output : Feb-20-Sat
dateUtil.evaluate("DDDD-MM-YYYY", { separator:  '/'}) // Output : Saturday/Feb/2020

// Logging
dateUtil.dateLog("Logging with timestamp") // Sun Feb 09 2020 22:40:58 GMT+0530 (IST) : Logging with timestamp


// Date Comparers
console.log(dateUtil.comparer("2019-9-15", "weeks")) 
// 21
console.log(dateUtil.comparer("2019-9-15", "days")) 
// 147
console.log(dateUtil.comparer("2019-9-15", "hours"))
// 3527
console.log(dateUtil.comparer("2019-9-15", "minutes"))
// 211650
console.log(dateUtil.comparer("2019-9-15", "absolute"))
// 4 months ago

Test

yarn test

Configs

| Parameter | Usage | |--|--| | separator | Provides separator for differentiating the readable date formate examples: '/', '--' | | today | Default converts today's date / 'false' to provide any other date : check examples for usage| | format | format only used when today is disabled. Provides date format examples: DD-MMMM-YYYY MM-DD-YYYY dd-mm-YYYY |

Short Months & Days

Short Day can be accessed by using "DD" in format : example Tue Long Day can be accessed by using "DDDD" in format: example Tuesday

Short Month can be accessed by using "MM" in format : example Sep Long Month can be accessed by using "MMMM" in format: example September

Date Comparer

Previous Date can be compared to today by simply accessing dateUtil.comparer

// Date Comparers
console.log(dateUtil.comparer("2019-9-15", "weeks")) 
// 21
console.log(dateUtil.comparer("2019-9-15", "days")) 
// 147
console.log(dateUtil.comparer("2019-9-15", "hours"))
// 3527
console.log(dateUtil.comparer("2019-9-15", "minutes"))
// 211650
console.log(dateUtil.comparer("2019-9-15", "absolute"))
// 4 months ago