-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
DateField will show previous day when timezone is negative #5116
Comments
Not sure we can do anything about it. We are just using the |
Can any one guide me how to run this project? |
I looked in to this problem because it is causing the e-2-e tests to fail on master when run in a negative timezone (GMT-700). If I create a post with a publish_at date of '2020-09-01', the date is sent to and return from the api as '2020-09-01', the problem occurs when the string is transformed into a date as follows
The result is 'Mon Aug 31 2020 17:00:00 GMT-0700 (Pacific Daylight Time)', which shows up in the DateInput/DateField as '2020-09-31'. The issue is that Proposed solutionI spent some time thinking about how this might be solved, but all of my ideas would involve breaking changes so would have to be saved for a major version bump. A workaround solution that I found is that when the date is returned from the api the timezone can be appended to the date string. The user can get the timezone from their system as shown below or they could pick some other way to set it.
This is something that people could easily add themselves. @djhi if you think this is a good idea I would be willing to add it into the documentation. (not sure if this should be raised in a different issue or here) The tests can be fixed by adding a time zone to the data.js file
would become
and in the tests
would become
I would be willing to make a pull request to fix the tests as well if you think it is a reasonable solution. |
… get around this bug marmelab/react-admin#5116, pin react version to 17.0.1
I'm in -3 timezone and as @djhi commented, I solved it setting the timeZone option to UTC: |
Fixed by #7242 |
I have the same issue in date Input on edit, what are your solutions? |
What you were expecting:
When displayed in a browser with negative timezone, for example America/Santiago (-04:00), DateField should show "2020/08/02" if the value of the date field is "2020-08-02".
What happened instead:
It shows "2020/08/01" instead.
Steps to reproduce:
Set a negative timezone to the browser like America/Santiago (-04:00). Set "2020-08-02" to a date field through DateInput. Then see the date column in the list and it will show "2020-08-01".
Environment
The text was updated successfully, but these errors were encountered: