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-to-iso-8601-string

v2.0.0

Published

Presents a JavaScript `Date` as a string in [ISO 8601 format](https://www.loc.gov/standards/datetime/iso-tc154-wg5_n0038_iso_wd_8601-1_2016-02-16.pdf), with support for the Extended (`YYYY-MM-DD`) and Basic (`YYYYMMDD`) variants

Downloads

95

Readme

date-to-iso-8601-string

Presents a JavaScript Date as a string in ISO 8601 format, with support for the Extended (YYYY-MM-DD) and Basic (YYYYMMDD) variants.

Note that this module uses the "local date" in the time zone of the machine, rather than the UTC dfate.

This package includes TypeScript types.

Installation

# With npm
npm install --save date-to-iso-8601-string

# With Yarn
yarn add date-to-iso-8601-string

Usage

Presenting a Date using the more common "Extended" (YYYY-MM-DD format)

// You can also import as a CommonJS module using `require`
import { dateToISO8601String } from 'date-to-iso-8601-string';

const date = new Date('2023-01-01');
dateToISO8601String(date);
//=> '2023-01-01'

Presenting a Date using the less common "Basic" (YYYY-MM-DD format)

import { dateToISO8601String, ISO8601DateFormat } from 'date-to-iso-8601-string';

const date = new Date('2023-01-01');
dateToISO8601String(date, ISO8601DateFormat.Basic);
//=> '20230101'

Development

  • This library code in src/ is written with Typescript.
    • You can compile it to native JavaScript module form (dist/esm) and CommonJS form (dist/commonjs) by running npm run build.
    • The code is automatically built before pushing to npm thanks to a prepublish hook.
  • Tests are implemented using Jest.
    • You can run the tests with npm run test.
  • Linting (including code formatting) is enforced with ESLint, augmented by Prettier.
    • You can check your code with npm run lint, and automatically fix many failures with npm run lint-and-fix.

The compilation, testing and build process are automatically run on pushed code using GitHub Actions.

With thanks to:

The following blog posts were very helpful for putting this - my first ever npm package - together!:

  • https://blog.logrocket.com/publishing-node-modules-typescript-es-modules/ (@jackfranklin)
  • https://blog.logrocket.com/testing-typescript-apps-using-jest/ (@ibywaks)
  • https://khalilstemmler.com/blogs/typescript/eslint-for-typescript/ (@stemmlerjs)
  • https://khalilstemmler.com/blogs/tooling/prettier/ (@stemmlerjs)