quasarframework / quasar-ui-qcalendar

QCalendar - Quasar App Extension, Vue CLI plug-in and UMD distributions available
https://quasarframework.github.io/quasar-ui-qcalendar
MIT License
421 stars 116 forks source link

getMonthNames returns incorrect array after midnight #389

Open JayNaire opened 1 year ago

JayNaire commented 1 year ago

Describe the bug quasar vite CLI q-calendar-month: in calendarChanged event handler: getMonthNames(...) should return say ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"] which it normally does. But sometimes it returns (say): ["Jan","Feb","Mar","Mar","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"] or maybe: ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Sep","Nov","Dec"]

I suspect it breaks when the system/browser clock ticks over midnight; I haven't tested exhaustively.

To Reproduce Using handler code adapted from https://qcalendar.netlify.app/developing/qcalendarmonth/month-navigation

const calendarChanged = (data) => {
  console.log('calendarChanged') // getMonthNames breaks (when system clock goes over midnight?)
  // const firstOfMonth = data.days.find(x => x.day==1) //OK
  const thisMonth = parseInt(selectedDate.value.split('-')[1]) //OK
  monthNum.value = thisMonth
  // monthStr.value = getMonthNames('long', 'en-US')[thisMonth - 1] // UNRELIABLE - corrupt array returned
  monthStr.value = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][thisMonth - 1] // OK - always works
  return 0
}