iamkun / iamkun/dayjs

.tz is not a function

Open
#1,379 11 comments 13 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Trying to use the timezone plugin but getting .tz() is not a function error.

**Information**
- 1.9.8
- React Native (Android)
- America/Vancouver

**Setup**
```
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';

dayjs.extend(utc);
dayjs.extend(timezone);

console.log(dayjs().tz('America/Vancouver'))
```

**Error**
```
[Wed Feb 10 2021 09:51:03.304] ERROR TypeError: (0, _dayjs.default)().tz is not a function. (In '(0, _dayjs.default)().tz('America/Vancouver')', '(0, _dayjs.default)().tz' is undefined)
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported React Native Android setup with dayjs/plugin/utc and dayjs/plugin/timezone, using version 1.9.8 and America/Vancouver. Check why the resulting dayjs instance lacks .tz(); done means the shown call works without the TypeError and the relevant regression is covered by an appropriate test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.