How to use the globalize.numberFormatter function in globalize

To help you get started, we’ve selected a few globalize examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github globalizejs / globalize-compiler / test / unit / fixtures / basic.js View on Github external
// Use parseDate.
console.log(Globalize.parseDate("1/2/1982"));

// Use parseDate in specific time zones.
console.log(Globalize.parseDate("January 1, 2000 at 12:00:00 AM EST", {
	datetime: "long",
	timeZone: "America/New_York"
}));

/**
 * Number
 */

// Use numberFormatter.
var numberFormatter = Globalize.numberFormatter({minimumFractionDigits: 0, maximumFractionDigits: 10});
console.log(numberFormatter(Math.PI));

// Use formatNumber.
console.log(Globalize.formatNumber(12345.6789));

// Use parseNumber.
console.log(Globalize.parseNumber("12345.6789"));

/**
 * Currency
 */

// Use currencyFormatter.
var currencyFormatter = Globalize.currencyFormatter("EUR");
console.log(currencyFormatter(9.99));
github globalizejs / globalize / examples / app-npm-webpack / app / index.js View on Github external
var Globalize = require( "globalize" );
var startTime = new Date();

// Standalone table.
var numberFormatter = Globalize.numberFormatter({ maximumFractionDigits: 2 });
document.getElementById( "number" ).textContent = numberFormatter( 12345.6789 );

var numberCompactFormatter = Globalize.numberFormatter({
	compact: "short",
	minimumSignificantDigits: 1,
	maximumSignificantDigits: 3
});
document.getElementById( "number-compact" ).textContent = numberCompactFormatter( 12345.6789 );

var currencyFormatter = Globalize.currencyFormatter( "USD" );
document.getElementById( "currency" ).textContent = currencyFormatter( 69900 );

var dateFormatter = Globalize.dateFormatter({ datetime: "medium" });
document.getElementById( "date" ).textContent = dateFormatter( new Date() );

var dateWithTimeZoneFormatter = Globalize.dateFormatter({
	datetime: "full",
	timeZone: "America/Sao_Paulo"
});
github globalizejs / globalize / examples / app-npm-webpack / app / index.js View on Github external
var Globalize = require( "globalize" );
var startTime = new Date();

// Standalone table.
var numberFormatter = Globalize.numberFormatter({ maximumFractionDigits: 2 });
document.getElementById( "number" ).textContent = numberFormatter( 12345.6789 );

var numberCompactFormatter = Globalize.numberFormatter({
	compact: "short",
	minimumSignificantDigits: 1,
	maximumSignificantDigits: 3
});
document.getElementById( "number-compact" ).textContent = numberCompactFormatter( 12345.6789 );

var currencyFormatter = Globalize.currencyFormatter( "USD" );
document.getElementById( "currency" ).textContent = currencyFormatter( 69900 );

var dateFormatter = Globalize.dateFormatter({ datetime: "medium" });
document.getElementById( "date" ).textContent = dateFormatter( new Date() );

var dateWithTimeZoneFormatter = Globalize.dateFormatter({