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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@opendevtools/rescript-intl

v4.0.0

Published

Parse dates and numbers using the Intl API in ReScript

Readme

rescript-intl

npm (scoped)

rescript-intl helps you with date, number and currency formatting in ReScript. Everything is built on top of Intl which comes built-in with browsers >= IE11 as well as Node.

Get started

npm install @opendevtools/rescript-intl

Add rescript-intl in bsconfig.json

{
  "dependencies": ["@opendevtools/rescript-intl"]
}

Examples

DateTime

let today = Intl.DateTime.make(~locale=Some("sv"), ());
// today: string = "2020-03-18"

with custom date

let date = Js.Date.makeWithYMD(~year=2020., ~month=11., ~date=12., ());

let futureDate = Intl.DateTime.make(~date, ~locale=Some("sv"), ());
// futureDate: string = "2020-12-12"

with date as string

let futureDate = Intl.DateTime.makeFromString(~date="2020-11-12", ~locale=Some("sv"), ());
// futureDate: string = "2020-11-12"

and with some options

let today =
  Intl.DateTime.make(
    ~locale=Some("sv"),
    ~options=
      Options.make(
        ~year=Some(#numeric),
        ~weekday=Some(#long),
        ~day=Some(#"2-digit"),
        ~era=Some(#narrow),
        ~month=Some(#long),
        (),
      ),
    (),
  );
// today: string = "onsdag 18 mars 2020 e.Kr".

NumberFormat

Currency

let krona =
  Intl.NumberFormat.Currency.make(
    ~value=1000.,
    ~currency="SEK",
    ~locale=Some("sv"),
    (),
  );
// krona: string = "1 000,00 kr"

Decimal

let parsedNumber =
  Intl.NumberFormat.Decimal.make(~value=1000., ~locale=Some("sv"), ());
// parsedNumber: string = "1 000,00"

Percent

let percent =
  Intl.NumberFormat.Percent.make(~value=0.3456., ~locale=Some("sv"), ());
// percent: string = "34,56 %"

ListFormat

// And based lists (default, #type = #conjunction) in Swedish
let data =
  Intl.ListFormat.make(["Cat", "Tiger", "Lion"], ~locale=Some("sv"), ());
// data: string = "Cat, Tiger och Lion"

// Or based lists
let data =
  Intl.ListFormat.make(["Cat", "Tiger", "Lion"],
  ~options=Options.make(~type_=Some(#disjunction), ()), ());
// data: string = "Cat, Tiger, or Lion"

// Unit based lists
let data =
  Intl.ListFormat.make(["Cat", "Tiger", "Lion"],
  ~options=Options.make(~type_=Some(#unit), ()), ());
// data: string = "Cat, Tiger, Lion"

let data =
  Intl.ListFormat.make(["Cat", "Tiger", "Lion"],
  ~options=Options.make(~type_=Some(#unit), ~style=Some(#narrow), ()), ());
// data: string = "Cat Tiger Lion"

Short, #short, and narrow, #narrow, styles are only available for #unit type. If you pass in any other type than #unit with those styles, the library takes care of it and changes the type to #unit.

Node

Node 13 added full ICU support and there should be no issues with wrong formatting. If you need to run a Node version before 13 it only has support for en-US locale by default. If your code is failing with wrong formatting you'll need to install full locale support using:

npm install -g full-icu

The installer will print out what you need to set the environment variable NODE_ICU_DATA to in order to get full support.