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

Corrected timezone handling for recurring events #231

Closed
wants to merge 6 commits into from

Conversation

fmos
Copy link

@fmos fmos commented Nov 2, 2022

... and fixed some apparent bugs along the way.

This includes new tests. All existing tests succeed.

Copy link
Owner

@jens-maus jens-maus left a comment

Choose a reason for hiding this comment

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

First of all, thank you for your submitted contribution. However, please be more verbose in what exactly you are trying to fix/change and explain why exactly are you doing a certain change.

Unfortunately, you changes are not self-explaining, thus I cannot fully follow or identify each individual change. So please explain in some more details each individual change/fix.

In addition, please take note that some unit test is failing with you changes incorporated. Thus, please check and correct that as well.

@@ -577,7 +591,9 @@ module.exports = {
// If the original date has a TZID, add it
if (curr.start.tz) {
const tz = getTimeZone(curr.start.tz);
rule += `;DTSTART;TZID=${tz}:${curr.start.toISOString().replace(/[-:]/g, '')}`;
const tzoffset = moment.tz(tz).utcOffset() * -60000;
Copy link
Owner

Choose a reason for hiding this comment

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

Why -60000 is required here? This smells like a modification for DST/non-DST which might not be valid in other time zones. Please explain.

Copy link
Author

Choose a reason for hiding this comment

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

In fact, the minus in -60000 compensates with the minus in Date(curr.start - tzoffset) in the next line in order to avoid a plus to be interpreted as implicit string concatenation. The factor 60000 is for conversion from minutes to milliseconds.

@@ -138,9 +138,19 @@ function getTimeZone(value) {
// And offset is still present
if (tz && tz.startsWith('(')) {
// Extract just the offset
const regex = /[+|-]\d*:\d*/;
const offsetcomps = tz.match(/([+|-]\d+):?(\d+)/);
Copy link
Owner

Choose a reason for hiding this comment

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

Please explain why exactly you changed that regex and what the added lines following this change try to fix/change.

Copy link
Author

Choose a reason for hiding this comment

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

I try to map indications like (GMT +02:00) to matching IANA etcetera zones, if available. The advantage of those IANA zone names is that they can be processed by moment-timezone.

if (tz && tz.startsWith('(')) {
// Extract just the offset
const regex = /[+|-]\d*:\d*/;
offset = tz.match(regex);
const offsetcomps = tz.match(/([+|-]\d+):?(\d+)/);
Copy link
Owner

Choose a reason for hiding this comment

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

same here, why is this regex change required?

Copy link
Author

Choose a reason for hiding this comment

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

The answer is the same as above.

@fmos
Copy link
Author

fmos commented Nov 11, 2022

Thank you for your review and detailed feedback!

In addition, please take note that some unit test is failing with you changes incorporated. Thus, please check and correct that as well.

Indeed, one of the tests is failing, which wasn't the case, when I committed this (before Oct 30). This could be a DST problem. I will look into it.

@satadhi4alumnux
Copy link

Just wanted to know is this PR going to get merge soon ?
I am stuck with this problem too.
Thank you.

@titanism
Copy link

titanism commented Feb 5, 2024

Bump

@50an6xy06r6n
Copy link
Contributor

This feels like a critical bug... not sure why this hasn't been figured out yet. I've put up an alternative solution in #329, which hopefully will be easier to review?

@jens-maus
Copy link
Owner

This issue has been resvoled via #329

@jens-maus jens-maus closed this Sep 2, 2024
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.

5 participants