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: adjust start & end of event when system timezone is using DST #1222

Merged
merged 2 commits into from
Jul 22, 2022

Conversation

adhrinae
Copy link
Contributor

Please check if the PR fulfills these requirements

  • It's the right issue type on the title
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx[,#xxx], where "xxx" is the issue number)
  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes/features)
  • Docs have been added/updated (for bug fixes/features)
  • It does not introduce a breaking change or has a description of the breaking change

Description

While rendering events, we need to calculate the offset difference if the system timezone is applicable to DST.

So we need to calculate it under the circumstance below:

  1. When the system timezone is using DST
  2. When the system timezone is not using DST(but applicable)

Thank you for your contribution to TOAST UI product. πŸŽ‰ 😘 ✨

@@ -32,7 +32,7 @@ export function calculateTimezoneOffset(timezoneName: string, targetDate: TZDate
'Intl.DateTimeFormat is not fully supported. So It will return the local timezone offset only.\nYou can use a polyfill to fix this issue.'
);

return -targetDate.getTimezoneOffset();
return -targetDate.toDate().getTimezoneOffset();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TZDate 의 getTimezoneOffset 이 Date 의 getTimezoneOffset κ³Ό μ•½κ°„ λ‹€λ₯Έλ°, 이 λ•Œλ¬Έμ— λ¬Έμ œκ°€ μ œλŒ€λ‘œ ν•΄κ²°λ˜μ§€ μ•Šκ³  μžˆμ—ˆμŠ΅λ‹ˆλ‹€. κ·Έλž˜μ„œ μ‹œμŠ€ν…œμ˜ νƒ€μž„μ‘΄μ„ μ •ν™•ν•˜κ²Œ κΊΌλ‚Ό ν•„μš”κ°€ 있기 λ•Œλ¬Έμ— toDate 둜 μ „ν™˜μ„ ν•΄ μ£Όμ—ˆμŠ΅λ‹ˆλ‹€.

@@ -170,6 +174,86 @@ DaylightSavingTimeTransitionSouthern.args = {
},
};

// NOTE: For manual testing purposes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ‹œμŠ€ν…œμ˜ νƒ€μž„μ‘΄μ„ λͺ¨ν‚Ήν•˜λŠ” λ™μž‘μ΄ μžλ™ν™”λœ ν…ŒμŠ€νŠΈ ν™˜κ²½μ—μ„œλŠ” μ–΄λ €μ› κΈ° λ•Œλ¬Έμ— 직접 ν…ŒμŠ€νŠΈμš© νŽ˜μ΄μ§€λ₯Ό μž‘μ„±ν•˜μ—¬ ν™•μΈν–ˆμŠ΅λ‹ˆλ‹€.

@@ -17,6 +19,7 @@ export function useEventsWithTimezone(events: Collection<EventModel>) {
return events;
}

const isSystemUsingDST = isUsingDST(new TZDate());
Copy link
Contributor Author

@adhrinae adhrinae Jul 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isUsingDST λŠ” 두 번째 인자둜 νƒ€μž„μ‘΄ 이름을 넣지 μ•Šμ„ 경우 ν˜„μž¬ μ‹œμŠ€ν…œμ„ κΈ°μ€€μœΌλ‘œ ν•΄λ‹Ή μ‹œκ°„μ˜ DST 적용 μ—¬λΆ€λ₯Ό κ²°μ •ν•©λ‹ˆλ‹€.

이λ₯Ό 톡해 λΈŒλΌμš°μ €κ°€ DST μ μš©μ€‘μΈμ§€ μ•„λ‹Œμ§€ 확인할 μˆ˜λ„ 있고, μ–΄λ–€ μ΄λ²€νŠΈκ°€ μ‹œμŠ€ν…œ νƒ€μž„μ‘΄ κΈ°μ€€μœΌλ‘œλŠ” DST μ μš©μ„ λ°›κ³  μžˆλŠ”μ§€ μ•„λ‹Œμ§€ 확인할 수 μžˆμŠ΅λ‹ˆλ‹€.

Copy link
Member

@dotaitch dotaitch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 μ™„λ£Œν•©λ‹ˆλ‹€.

@adhrinae adhrinae merged commit 95b6e12 into main Jul 22, 2022
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.

None yet

2 participants