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

[bug]: Calendar widget adds a date prior to the selected date #3305

Closed
1 task done
Huuuze opened this issue Jan 2, 2024 · 6 comments
Closed
1 task done

[bug]: Calendar widget adds a date prior to the selected date #3305

Huuuze opened this issue Jan 2, 2024 · 6 comments

Comments

@Huuuze
Copy link

Huuuze commented Jan 2, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

When editing an issue, if you select a value for either Start Date or End Date, the value is the day prior to the selected date (i.e., I select "January 5, 2024", but January 4, 2024" is displayed instead).

Screen.Recording.2024-01-02.at.3.54.47.PM.mov

Steps to reproduce

See the screen-recording above.

This issue exists in Firefox 121 and Chromium 120.0.6099.144

Browser

Mozilla Firefox

Version

Self-hosted

@Huuuze
Copy link
Author

Huuuze commented Jan 17, 2024

I believe I've found the error.

https://github.com/makeplane/plane/blob/preview/web/helpers/date-time.helper.ts#L186C22-L186C22

The method, "renderShortDate()", accepts a date string with this format: "2024-01-17". This value is cast into a Date object, but it does not include a time. The lack of a time value creates a problem here; the Date object appears to use the user's local timezone.

So, when using "Date.getDate()" to return the day value of the date string, the timezone ends up displaying the wrong day value. This code snippet demonstrates the problem; I believe the resolution is to use Date.getUTCDate().


const birthday = new Date('2024-01-17');
const non_utc_date = birthday.getDate();
const utc_date = birthday.getUTCDate();

// Expected output: 17
console.log(non_utc_date); //16
console.log(utc_date); //17

For what it's worth, the value in the database is correct -- the renderer is simply showing the wrong value.

@Marinofull
Copy link

I got this same error, it is caused here because I'm in a negative timezone (gmt -3) so when it renders displays the wrong date. If I switch pc hour to a positive timezone, the bug disappear. It might be required a normalization of the date object before renders it on the screen.

@Marinofull
Copy link

I can confirm this bug is still present on v0.15.0

@ghost
Copy link

ghost commented Feb 7, 2024

@Marinofull I can as well, hoping this well be fixed in the next release!

@ovvesley
Copy link

I can confirm this bug is still present on v0.16.0.

@pushya22
Copy link
Collaborator

pushya22 commented Apr 4, 2024

This issue is resolved in PR #3992

@pushya22 pushya22 closed this as completed Apr 4, 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

No branches or pull requests

4 participants