filters.js 981 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2019 Hackware SpA <human@hackware.cl>
  2. // This file is part of "Hackware Userland" and licensed under the terms
  3. // of the GNU Affero General Public License version 3, or (at your option)
  4. // a later version. You should have received a copy of this license along
  5. // with the software. If not, see <https://www.gnu.org/licenses/>.
  6. import Vue from 'vue';
  7. const currencyFormatter = new Intl.NumberFormat('es-CL', {
  8. style: 'currency',
  9. currency: 'CLP',
  10. });
  11. const dateTimeFormatter = new Intl.DateTimeFormat('es-CL', {
  12. year: 'numeric',
  13. month: 'numeric',
  14. day: 'numeric',
  15. hour: 'numeric',
  16. minute: 'numeric',
  17. hourCycle: 'h23',
  18. });
  19. const dateFormatter = new Intl.DateTimeFormat('es-CL', {
  20. year: 'numeric',
  21. month: 'numeric',
  22. day: 'numeric',
  23. });
  24. Vue.filter('datetime', value => dateTimeFormatter.format(new Date(value)));
  25. Vue.filter('date', value => dateFormatter.format(new Date(value)));
  26. Vue.filter('currency', value => currencyFormatter.format(value));