utils.mjs 477 B

1234567891011121314
  1. import { padZero } from "../utils/index.mjs";
  2. function getDate(timeStamp) {
  3. const date = new Date(timeStamp * 1e3);
  4. return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
  5. date.getDate()
  6. )}`;
  7. }
  8. const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
  9. const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
  10. export {
  11. formatAmount,
  12. formatDiscount,
  13. getDate
  14. };