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

utc-to-month-yyyy

v1.0.2

Published

A simple package that takes the date in UTC format and returns date in Month-YYYY format

Downloads

12

Readme

format-date-Month-Year

npm version npm downloads license

A simple Node.js utility to convert a date string from UTC to the format Month-YYYY. This package checks for valid dates and ensures the date falls within a reasonable range (between the years 1000 and 9999).

🌟 Features

  • Date Conversion: Converts a UTC date string to the format MM-YYYY (e.g., "July 2024").
  • Validation: Returns "Invalid Date" if the input is not a valid date.
  • Range Check: Returns "Out of Range" if the date falls outside the years 1000 to 9999.

📦 Installation

You can install the package using npm:

npm install utc-to-month-yyyy

🚀 Usage

To use this package, simply require it in your Node.js project and pass the UTC date string as an argument:

 const formatDateMMYYYY = require('format-date-mm-yyyy');

 const formattedDate = formatDateMMYYYY('2024-07-21T15:00:00Z');

 console.log(formattedDate); // Outputs: "July 2024"

Input Parameters :

inputDateString (required): The UTC date string to be formatted. Example: "2024-07-21T15:00:00Z".

outputFormat (optional):

The format of the output string. Currently, only MM-YYYY format is supported.

Return Values :

Formatted Date: Returns a string in the format MM-YYYY (e.g., "July 2024").

"Invalid Date": Returned if the input date string is not valid.

"Out of Range": Returned if the date falls outside the range of years 1000 to 9999.

📝 Examples

Valid Date Input:

const formatDateMMYYYY = require('format-date-mm-yyyy');

const date1 = formatDateMMYYYY('2023-11-15T00:00:00Z');
console.log(date1); // Outputs: "November 2023"

Invalid Date Input: const formatDateMMYYYY = require('format-date-mm-yyyy');

const date2 = formatDateMMYYYY('invalid-date-string');
console.log(date2); // Outputs: "Invalid Date"

Out of Range Date Input:

const formatDateMMYYYY = require('format-date-mm-yyyy');

const date3 = formatDateMMYYYY('0500-01-01T00:00:00Z');
console.log(date3); // Outputs: "Out of Range"

🧪 Testing

You can run a quick test using Node.js by creating a file, say test.js, and adding the following code:

const formatDateMMYYYY = require('./index');

console.log(formatDateMMYYYY('2024-07-21T15:00:00Z')); // Outputs: "July 2024"
console.log(formatDateMMYYYY('invalid-date-string'));  // Outputs: "Invalid Date"
console.log(formatDateMMYYYY('0500-01-01T00:00:00Z')); // Outputs: "Out of Range"

Run the file using: node test.js

📄 License

This package is licensed under the MIT License.

🤝 Contribution

Feel free to fork the repository and submit pull requests for any improvements or additional features.

👤 Author

Suhas Marabasannavar - (https://github.com/Suhas2299)