Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using of "dayjs/plugin/timezone" causes Uncaught TypeError: Cannot set property of undefined #1351

Closed
d-reznik opened this issue Jan 22, 2021 · 4 comments

Comments

@d-reznik
Copy link

Describe the bug
I have this small code where I try to use tz function:

import dayjs from 'dayjs';
import timeZone from "dayjs/plugin/timezone";
dayjs.extend(timeZone);

const currentTime = dayjs().tz("Europe/Copenhagen");

On the last line I get an error in Chrome console:

timezone.js?1953:1 Uncaught TypeError: Cannot set property '$timezone' of undefined

I tried to copy paste all the examples from documentation and non of timezone examples worked for me. Could you please tell me what am I doing wrong?

Expected behavior
Function tz can be used in my code.

Information

  • Day.js Version v1.10.0/v1.10.3/v1.10.4
  • OS: Win 10
  • Browser chrome 87
  • Time zone: GMT+02:00
@iamkun
Copy link
Owner

iamkun commented Jan 22, 2021

can you provide a reproduction repo?

@d-reznik
Copy link
Author

can you provide a reproduction repo?

Thank you for reply!
Here is my repo to reproduce this issue: https://github.com/d-reznik/dayjs_repro
Next error happens in MainPage.vue component in property currentCopenhagenTime

Uncaught TypeError: Cannot set property '$timezone' of undefined
    at d.s.tz (timezone.js?1953:1)
    at Proxy.get (MainPage.vue?3552:17)
    at ComputedRefImpl.reactiveEffect [as effect] (reactivity.esm-bundler.js?a1e9:42)
    at ComputedRefImpl.get value [as value] (reactivity.esm-bundler.js?a1e9:827)
    at Object.get [as currentCopenhagenTime] (runtime-core.esm-bundler.js?5c40:5783)
    at Object.get (runtime-core.esm-bundler.js?5c40:6097)
    at Proxy.render (MainPage.vue?67f4:3)
    at renderComponentRoot (runtime-core.esm-bundler.js?5c40:710)
    at componentEffect (runtime-core.esm-bundler.js?5c40:4193)
    at reactiveEffect (reactivity.esm-bundler.js?a1e9:42)

@iamkun
Copy link
Owner

iamkun commented Jan 25, 2021

you can check the doc here https://day.js.org/docs/en/timezone/parsing-in-zone

Timezone plugin depends on utc plugin

@d-reznik
Copy link
Author

you can check the doc here https://day.js.org/docs/en/timezone/parsing-in-zone

Timezone plugin depends on utc plugin

Thank you very much! This solved my problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants