`dayjs.tz` incorrectly handles offsets containing minutes and seconds
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Creating a date with a timezone offset that contains minutes and seconds is not properly handled by `dayjs.tz` function. Offset seems to be rounded to a nearest hour and newly created `dayjs.Dayjs` object provides incorrect time information.
For example, timezone in Kyiv up until 1924 had an offset of UTC+02:02:04 (https://www.timeanddate.com/time/zone/ukraine/kyiv):

In Moment.js library this edge case is handled correctly. Here is a simple test that demonstrates how `dayjs.tz` should behave:
```ts
describe('tz', () => {
describe('given a timezone with UTC+02:02:04 offset', () => {
test('handles it correctly', () => {
const kiev = dayjs('1900-06-01T12:00:00Z').tz('Europe/Kiev');
const Mkiev = moment('1900-06-01T12:00:00Z').tz('Europe/Kiev');
expect(kiev.format()).toBe('1900-06-01T14:02:04+02:02');
expect(kiev.format()).toBe(Mkiev.format());
expect(kiev.valueOf()).toBe(-2195899200000);
expect(kiev.valueOf()).toBe(Mkiev.valueOf());
expect(kiev.utcOffset()).toBe(122.06666666666666);
expect(kiev.utcOffset()).toBe(Mkiev.utcOffset());
expect(kiev.utc().format()).toBe("1900-06-01T12:00:00Z");
expect(kiev.utc().format()).toBe(Mkiev.utc().format());
});
});
});
```
**Information**
- Day.js Version: 1.11.2
- OS: Windows 10, version 21H2
- Browser: Node.js 16.15.0
- Time zone: [Europe/Vilnius](https://en.wikipedia.org/wiki/Time_in_Lithuania) (UTC offset: +02:00; DST: +03:00)
Contributor guide
Research direction
Start at the dayjs.tz entry point and reproduce the supplied Europe/Kiev case for the UTC+02:02:04 historical offset. Compare the result with the expected format, value, offset, and UTC output in the issue's test; done means all assertions match the shown expectations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100