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

fix(time): infinite loop for ticks of Berlin time #208

Merged
merged 1 commit into from
Dec 18, 2023
Merged

Conversation

pearmini
Copy link
Member

@pearmini pearmini commented Dec 18, 2023

修复时区带来的死循环

fix: ant-design/ant-design-charts#2297

上面的 issue 经过简单排查是 time scale 计算 ticks 算法造成死循环。

存在问题

出现的问题第一眼看很难理解: date.setTime(date + DURATION_WEEK)date.setDate(date.getDate() + 7) 的结果不一样!在原本代码中是使用的第一种:该表达式并没有增加一周的时间,少了一个小时,这也导致了死循环。

iShot_2023-12-18_07 49 48

问题原因

这问题只对特定的时间和时区有关,于是问了问 GPT 老师,发现欧洲会在10月在最后的一个周日左右会把时间调快一个小时,所以通过时间戳计算会比实际时间少一个小时。

iShot_2023-12-18_07 50 24

解决办法

date.setDate(date.getDate() + 7) 计算偏移时间。

@pearmini pearmini force-pushed the fix/timezone branch 2 times, most recently from b2a2041 to 14e1748 Compare December 18, 2023 07:19
@pearmini pearmini merged commit 70c03b0 into master Dec 18, 2023
5 checks passed
@pearmini pearmini deleted the fix/timezone branch December 18, 2023 08:44
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

Successfully merging this pull request may close these issues.

🐛[BUG] Browser Crash with Date values
2 participants