mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
25 lines
No EOL
553 B
CoffeeScript
25 lines
No EOL
553 B
CoffeeScript
dateformat = require 'dateformat'
|
|
settings = require "settings-sharelatex"
|
|
|
|
|
|
currenySymbols =
|
|
EUR: "€"
|
|
USD: "$"
|
|
GBP: "£"
|
|
|
|
|
|
|
|
module.exports =
|
|
|
|
formatPrice: (priceInCents, currency = "USD") ->
|
|
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)
|
|
symbol = currenySymbols[currency]
|
|
return "#{symbol}#{dollars}.#{cents}"
|
|
|
|
formatDate: (date) ->
|
|
dateformat date, "dS mmmm yyyy" |