Socket
Socket
Sign inDemoInstall

intl-io

Package Overview
Dependencies
0
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    intl-io

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


Version published
Weekly downloads
911
increased by17.1%
Maintainers
1
Install size
140 kB
Created
Weekly downloads
 

Readme

Source

intl-io

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 three formats:

  • ES Module: dist/index.m.js
  • CommonJS: dist/index.cjs.js
  • UMD: dist/index.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'); //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

FormatDescriptionResult
yyyyMMddShort date09/07/2019
yyyyMMMddMedium dateSep 07, 2019
HHmmShort time09:35 PM
HHmmNShort time21:35
yyyyMMMddHHmmFull date timeSep 07, 2019 09:35 PM
Format Specifiers
SpecifierPart
y, Yyear
Mmonth
Dday name
dday
h, Hhours
m, iminutes
s, Sseconds
a, Ahour12 AM/PM
p, Phour12 AM/PM
n, Nhour24
t, Ttimezone
u, UUTC timezone
z, ZUTC timezone

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

License

MIT © Codaxy

FAQs

Last updated on 28 Aug 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc