quasar-ui-qcalendar icon indicating copy to clipboard operation
quasar-ui-qcalendar copied to clipboard

getMonthNames returns incorrect array after midnight

Open JayNaire opened this issue 1 year ago • 0 comments

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
}

JayNaire avatar Jul 07 '22 09:07 JayNaire