`dayjs.tz()` needs to have timezone parameter as optional
See original GitHub issueDescribe the bug
Because you can set a default timezone, the dayjs.tz()
method should have the second parameter (timezone) as optional. It works fine in JS — just missing the correct types for TS.
Expected behavior
- Set
dayjs.tz.setDefault("America/Phoenix");
dayjs.tz('some valid date')
<- that shouldn’t throw a TypeScript errordayjs('some valid date').tz()
<- that shouldn’t throw a TypeScript error either
Potential Solution
declare module 'dayjs' {
interface Dayjs {
tz(timezone?: string): Dayjs;
}
interface DayjsTimezone {
(date?: ConfigType, timezone?: string): Dayjs;
}
}
Information
- Day.js Version: v1.8.36
- OS: macOS v10.15.6
- Browser: Firefox Developer Edition v82.0b2
- Time zone: America/Phoenix
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Time Zone
Day.js supports time zone via the Internationalization API in supported environments. By using the native API, no extra bytes of timezone data need...
Read more >Dayjs format with timezone abbreviation i.e. 'z' like in moment.js
I have added the utc and timezone plugins and can't see any other plugins needed to make this work, I notice on Dayjs...
Read more >Date.prototype.toLocaleTimeString() - JavaScript | MDN
The toLocaleTimeString() method returns a string with a language-sensitive representation of the time portion of the date.
Read more >Demystifying DateTime Manipulation in JavaScript - Toptal
now() to directly get the time stamp without having to create a new Date object. Parsing a Date. Converting a string to a...
Read more >Class Dayjs - @formio/core
Parameters. Optional config: null | string | number | Date | Dayjs ... Still, dayjs#clone can create a clone of the current object...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
🎉 This issue has been resolved in version 1.9.0 🎉
The release is available on:
Your semantic-release bot 📦🚀
True, would you like pulling request for this?