Timezone plugin returns incorrect values or null
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
The Timezone plugin returns incorrect values or null on iOS when Hermes engine is enabled.
**Information**
- Day.js: 1.11.7
- OS: iOS
- React Native: 0.71
- Time zone: GMT+01:00
**Steps to reproduce**
1. `npx react-native init AwesomeProject`
2. `yarn add dayjs`
**Code example**
```
import React from 'react';
import {SafeAreaView} from 'react-native';
import dayjs from 'dayjs';
import timezoneDayjsPlugin from 'dayjs/plugin/timezone';
import utcDayjsPlugin from 'dayjs/plugin/utc';
dayjs.extend(utcDayjsPlugin);
dayjs.extend(timezoneDayjsPlugin);
const App = () => {
// #1 Converting to a timezone
const timestamp = '2013-11-18 11:55';
const tz = 'Asia/Taipei';
console.log(
'Converting to a timezone',
dayjs
.utc('2013-11-18 11:55')
.tz('Asia/Taipei')
.format(),
);
// #2 Parsing in a timezone
console.log(
'Parsing in a timezone',
dayjs.tz(timestamp, tz).format(),
);
return ;
};
export default App;
```
**Actual behavior**
```
LOG Converting to a timezone Invalid Date
LOG Parsing in a timezone 2013-11-18T12:08:00+07:55
```
**Expected behavior**
```
LOG Converting to a timezone 2013-11-18T19:55:00+08:00
LOG Parsing in a timezone 2013-11-18T11:55:00+08:00
```
For React Native < 0.70 timezone plugin doesn't work at all, right now it works but returned values are incorrect.
Contributor guide
Research direction
Start by reproducing the two timezone-plugin calls in the provided React Native example with Hermes enabled, using the reported iOS and Day.js versions. Trace the timezone plugin behavior for conversion and parsing, and consider the issue done when both calls produce the expected formatted values rather than Invalid Date or an incorrect offset.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100