Ask questionsTypeError: weeks[0] is undefined when using Change Timezone extension

With this extension enabled, I keep getting this error, both in Firefox, and Chrome, no matter which timezone I choose:


Current real date on my PC is 2019-10-19 19:41, Saturday.

Smallest reproducible example code:

    import Datepicker from 'svelte-calendar'
    let selected
    const format = "#{l}, #{j} #{F} #{Y}"
<Datepicker {format} bind:selected />

I don't think any of my users will have this extension installed, but this behaviour shouldn't happen nonetheless.


Answer questions pzmarzly

I dug for a bit, and found out that there is a problem with Date.getMonth() when using that extension (it e.g. still reports September on 2019-10-01 00:00, unlike the JS API). This is definitely extension's bug, not svelte-calendar's. It looks like it could be worked around by changing these lines:

-  let date = new Date(year, month, 1);
+  let date = new Date(year, month, 1, 15);
-  let date = new Date(start.getFullYear(), start.getMonth(), 1);
+  let date = new Date(start.getFullYear(), start.getMonth(), 1, 15);

, but I don't suggest we do that - I'm leaving this just for future reference.

Looking at that extension's review page, I can see svelte-calendar is not the only calendar affected:

after a few days of use: breaks a number of sites, including flight booking at (calendars do not work at all) and managing my Mikrotik router (all dates are incorrect by a day.)

I'll try contacting the extension's author. Anyway, the issue can be closed.

Do you have more specific steps needed to reproduce the issue you're seeing?

Sadly, not really. The bug also happens on my Ubuntu VM with clear Firefox (aside of that extension), English (US) locale. I tried setting different timezones, it made no difference.


Related questions

No questions were found.
Github User Rank List