SubscriptionFormatters.coffee 394 B

123456789101112131415
  1. dateformat = require 'dateformat'
  2. module.exports =
  3. formatPrice: (priceInCents) ->
  4. string = priceInCents + ""
  5. string = "0" + string if string.length == 2
  6. string = "00" + string if string.length == 1
  7. string = "000" if string.length == 0
  8. cents = string.slice(-2)
  9. dollars = string.slice(0, -2)
  10. return "$#{dollars}.#{cents}"
  11. formatDate: (date) ->
  12. dateformat date, "dS mmmm yyyy"