How to use the numbro.culture function in numbro

To help you get started, we’ve selected a few numbro 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 hustcer / star / lib / insider.js View on Github external
cmd       = require('commander'),
    columnify = require('columnify');

/* eslint no-useless-escape:0 */
let start   = new Date().getTime();
let conf    = require('./conf').conf;
let Iconv   = require('iconv').Iconv;
let iconv   = new Iconv('GBK', 'UTF-8//TRANSLIT//IGNORE');
let request = require('request');
let Common  = require('./common').Common;

let from = null;
let to   = null;
let ft   = conf.fmt;

numbro.culture('zh-CN', conf.numbro);
// switch between languages
numbro.culture('zh-CN');
numbro.zeroFormat('N/A');
numbro.defaultFormat(ft.common);

/**
 * 各类提示信息
 * @type {Object}
 */
const MSG = {
    NO_TRADING      : '在当前时间范围内无董监高交易记录!',
    PARAM_ERROR     : '参数输入错误,请检查后重试!',
    INPUT_ERROR     : '输入错误,当前只支持通过单只证券代码查询,请重新输入!',
    REQUEST_ERROR   : '数据请求错误,请重试!错误信息:\n',
    SYSTEM_BUSY     : '系统正忙,请稍后再试!\n',
    SHOW_DETAIL_TIP : '  具体交易记录省略,可通过 "--show-detail" 参数查看详情...',
github opencollective / opencollective-website / frontend / src / lib / format_currency.js View on Github external
// This is necessary because if only one option field is passed, the other becomes undefined
  // Feels like there must be a better way to pass options
  options.precision = (options.precision === undefined) ? 2 : options.precision;
  options.compact = (typeof options.compact === 'boolean') ? options.compact : true;

  let lang = 'en-US';
  switch (currency) {
    case 'EUR': lang = 'fr-FR';
          break;
    case 'SEK': lang = 'sv-SE';
          break;
    case 'GBP': lang = 'en-GB';
          break;
  }

  Numbro.culture(lang);

  // remove the negative sign from the value
  const number = Numbro(value/100);
  let formatted = (options.precision === 0) ? number.format('$0,0') : number.format('$0,0.00');

  if (!options.compact) {
    formatted = `${currency} ${formatted}`;
  }
  return formatted;
};
github hustcer / star / lib / insider.js View on Github external
/* eslint no-useless-escape:0 */
let start   = new Date().getTime();
let conf    = require('./conf').conf;
let Iconv   = require('iconv').Iconv;
let iconv   = new Iconv('GBK', 'UTF-8//TRANSLIT//IGNORE');
let request = require('request');
let Common  = require('./common').Common;

let from = null;
let to   = null;
let ft   = conf.fmt;

numbro.culture('zh-CN', conf.numbro);
// switch between languages
numbro.culture('zh-CN');
numbro.zeroFormat('N/A');
numbro.defaultFormat(ft.common);

/**
 * 各类提示信息
 * @type {Object}
 */
const MSG = {
    NO_TRADING      : '在当前时间范围内无董监高交易记录!',
    PARAM_ERROR     : '参数输入错误,请检查后重试!',
    INPUT_ERROR     : '输入错误,当前只支持通过单只证券代码查询,请重新输入!',
    REQUEST_ERROR   : '数据请求错误,请重试!错误信息:\n',
    SYSTEM_BUSY     : '系统正忙,请稍后再试!\n',
    SHOW_DETAIL_TIP : '  具体交易记录省略,可通过 "--show-detail" 参数查看详情...',
};
github DeviaVir / zenbot / 3x / utils / format_currency.js View on Github external
module.exports = function (val, currency) {
  var culture = n.culture()
  var ret
  switch (currency) {
    case 'USD': n.setCulture('en-US'); break;
    case 'EUR': n.setCulture('fr-FR'); break;
    case 'CNY': n.setCulture('zh-CN'); break;
    case 'BTC': return n(val).format('0.00000000')
    default: return n(val).format('0.000');
  }
  ret = n(val).formatCurrency('$,0.00')
  n.setCulture(culture)
  return ret
}