New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nativescript-intl

Package Overview
Dependencies
Maintainers
9
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-intl

Provides API for using Native date, time and number formatting with an API similar to Intl.js

  • 4.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
501
decreased by-3.47%
Maintainers
9
Weekly downloads
 
Created
Source

Welcome to the nativescript-intl plugin for NativeScript framework

Prerequisites

  • installed NativeScript
  • installed NativeScript-CLI

Install nativescript-intl plugin.

Navigate to project folder and run NativeScript-CLI command tns plugin add nativescript-intl.

This plugin provides similar to Intl.js API for date, time and number formatting on a mobile device (Android and iOS).

How to use

var intl = require("nativescript-intl");
var dateFormat = new intl.DateTimeFormat('en-US', {'year': 'numeric', 'month': 'short', 'day': 'numeric'}).format(new Date(2016, 2, 23));
var numberFormat = new intl.NumberFormat('en-US', {'style': 'currency', 'currency': 'USD', 'currencyDisplay': 'symbol'}).format(123456.789);

console.log("dateFormat: " + dateFormat);
console.log("numberFormat: " + numberFormat);
// prints Mar 23, 2016
// $123456.79

Since localization formatting is not exactly same on Android, iOS and Intl.js there is another option to use this API.

Custom pattern

var intl = require("nativescript-intl");
var dateFormat = new intl.DateTimeFormat(null, null, 'y MMMM d, EEEE HH:mm:ss').format(new Date(2016, 2, 23, 12, 35, 40));
var numberFormat = new intl.NumberFormat('en-US', {'style': 'currency', 'currency': 'USD', 'currencyDisplay': 'symbol'}, '#,##0.00 ¤').format(123456.789);

console.log("dateFormat: " + dateFormat);
console.log("numberFormat: " + numberFormat);
// prints 2016 March 23, Wednesday 2016 12:35:40
// 123,456.79 $

Omitting locale will use the current locale setting on device.

Keep in mind that ICU versions differ accross device OS versions, so this plugin could produce different results on a different API level (Android) and OS version (iOS).

Keywords

FAQs

Package last updated on 03 Sep 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc