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

intl-io

v0.4.3

Published

Number and date formatting and parsing based on ECMAScript Internationalization API (Intl).

Downloads

12,588

Readme

Culture specific date/time and number formatting and parsing based on ECMAScript Internationalization API (Intl).

Used for localized calendars, date fields and number fields in CxJS.

This module is available in four formats:

  • CommonJS: dist/intl-io.js
  • ES Module: dist/intl-io.module.js
  • Modern ES Module: dist/intl-io.modern.js
  • UMD: dist/intl-io.umd.js

Install

$ npm install intl-io --save

Usage

import { DateTimeCulture, NumberCulture } from 'intl-io';

let dateCulture = new DateTimeCulture('es');
dateCulture.format(new Date(), 'yyyyMMdd'); //28/08/2019
dateCulture.format(new Date(), 'yyyyMMMdd'); //28 ago. 2019
dateCulture.format(new Date(), 'yyyyMMdd'); //28 de agosto de 2019
dateCulture.format(new Date(), 'yyyyMMddDDD'); //mié., 28 de agosto de 2019
let date = culture.parse('mié., 28 de agosto de 2019', { loose: true }); //Aug 28, 2019

let numberCulture = new NumberCulture('de');
let formatter = numberCulture.getFormatter({
    style: 'currency',
    currency: 'EUR',
});
let currency = formatter.format(5555.5); //5.555,50 €
let number = numberCulture.parse('5.555,5'); //5555.5

For number formatting options look at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat.

Date time formatting

Some parts support different length. Four digits means full name, three digits is a long form, two digits is medium and one digit is short form.

  • YYYY - full year (e.g. 2019)
  • YY - short year (e.g. 19)
  • MMMM - long month name (e.g. August)
  • MMM - short month name (e.g. Aug)
  • MM - two digit month (e.g. 08)
  • M - numeric month (e.g. 8)
  • DDDD - full day name (e.g. Monday)
  • DDD - short day name (e.g. Mon)
  • DD - short day name (e.g. Mo)
  • D - short day name (e.g. M)

Examples

| Format | Description | Result | | --------------- | -------------- | --------------------- | | yyyyMMdd | Short date | 09/07/2019 | | yyyyMMMdd | Medium date | Sep 07, 2019 | | HHmm | Short time | 09:35 PM | | HHmmN | Short time | 21:35 | | yyyyMMMddHHmm | Full date time | Sep 07, 2019 09:35 PM |

Format Specifiers

| Specifier | Part | | --------- | ------------ | | y, Y | year | | M | month | | D | day name | | d | day | | h, H | hours | | m, i | minutes | | s, S | seconds | | a, A | hour12 AM/PM | | p, P | hour12 AM/PM | | n, N | hour24 | | t, T | timezone | | u, U | UTC timezone | | z, Z | UTC timezone |

For detailed date formatting options look at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat.

License

MIT © Codaxy