import { boot } from 'quasar/wrappers'; import { date as quasarDate } from 'quasar'; const { formatDate } = quasarDate; export default boot(() => { Date.vnUTC = () => { const env = process.env.NODE_ENV; if (!env || env === 'development') return new Date(Date.UTC(2001, 0, 1, 11)); return new Date(); }; Date.vnNew = () => { return new Date(Date.vnUTC()); }; Date.vnNow = () => { return new Date(Date.vnUTC()).getTime(); }; Date.vnFirstDayOfMonth = () => { const date = new Date(Date.vnUTC()); return new Date(date.getFullYear(), date.getMonth(), 1); }; Date.vnLastDayOfMonth = () => { const date = new Date(Date.vnUTC()); return new Date(date.getFullYear(), date.getMonth() + 1, 0); }; Date.getCurrentDateTimeFormatted = ( options = { startOfDay: false, endOfDay: true, iso: true, mask: 'DD-MM-YYYY HH:mm', }, ) => { const date = Date.vnUTC(); if (options.startOfDay) { date.setHours(0, 0, 0); } if (options.endOfDay) { date.setHours(23, 59, 0); } if (options.iso) { return date.toISOString(); } return formatDate(date, options.mask); }; Date.convertToISODateTime = (dateTimeStr) => { const [datePart, timePart] = dateTimeStr.split(' '); const [day, month, year] = datePart.split('-'); const [hours, minutes] = timePart.split(':'); const isoDate = new Date(year, month - 1, day, hours, minutes); return isoDate.toISOString(); }; });