2014-02-12 05:23:40 -05:00
|
|
|
dateformat = require 'dateformat'
|
2014-09-08 05:59:12 -04:00
|
|
|
settings = require "settings-sharelatex"
|
|
|
|
|
|
|
|
|
|
|
|
currenySymbols =
|
|
|
|
EUR: "€"
|
|
|
|
USD: "$"
|
|
|
|
GBP: "£"
|
2015-01-07 11:51:05 -05:00
|
|
|
SEK: "kr"
|
|
|
|
CAD: "$"
|
|
|
|
NOK: "kr"
|
|
|
|
DKK: "kr"
|
|
|
|
AUD: "$"
|
|
|
|
NZD: "$"
|
|
|
|
CHF: "Fr"
|
|
|
|
SGD: "$"
|
2014-09-08 05:59:12 -04:00
|
|
|
|
2014-02-12 05:23:40 -05:00
|
|
|
|
|
|
|
module.exports =
|
|
|
|
|
2014-09-08 05:59:12 -04:00
|
|
|
formatPrice: (priceInCents, currency = "USD") ->
|
2014-02-12 05:23:40 -05:00
|
|
|
string = priceInCents + ""
|
|
|
|
string = "0" + string if string.length == 2
|
|
|
|
string = "00" + string if string.length == 1
|
|
|
|
string = "000" if string.length == 0
|
|
|
|
cents = string.slice(-2)
|
|
|
|
dollars = string.slice(0, -2)
|
2014-09-08 05:59:12 -04:00
|
|
|
symbol = currenySymbols[currency]
|
|
|
|
return "#{symbol}#{dollars}.#{cents}"
|
2014-02-12 05:23:40 -05:00
|
|
|
|
|
|
|
formatDate: (date) ->
|
2018-11-19 10:44:51 -05:00
|
|
|
return null if !date?
|
2014-02-12 05:23:40 -05:00
|
|
|
dateformat date, "dS mmmm yyyy"
|