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

UTC Date shows correct data in admin form, but one day earlier in admin list #4840

Closed
alsoicode opened this issue Oct 27, 2018 · 8 comments
Closed

Comments

@alsoicode
Copy link
Contributor

Expected behavior

A Date field stored in UTC time should show the same value in the model list view and when editing

Actual/Current behavior

Keystone admin shows the correct value for a Date field with the utc: true option set, but after saving, the list will display the date one day early.

Steps to reproduce the actual/current behavior

Create a model with a Date field and the utc: true option enabled.
Save an instance of your model.

Environment

Software Version
Keystone 4.0.0
Node.js 10.11.0
Browser Any
@alsoicode
Copy link
Contributor Author

alsoicode commented Oct 27, 2018

Here's a pull request for this issue: https://github.com/keystonejs/keystone/pull/4841

I have verified that this is working correctly for me in a production setting where my server is in a different timezone that my client machine and also running locally.

I implemented the same moment.utc() formatting pattern present in DateField.js for consistency. The only difference is the property that's accessed to check for .isUTC

@autoboxer
Copy link
Contributor

@alsoicode, if you're interested in working with me on shoring up additional date issues, let me know, I have a few I'm planning on working on from formatting to handling a missing default, to UTC within Relationship fields referencing a model. Regardless, thanks for your help on this issue.

@alsoicode
Copy link
Contributor Author

Sure, I'd love to help. I'm very busy on a project for work this week, as it's the last week of our current sprint, but I might be able to make some time in the evening. Are there existing issues for the things you want to work on you could point me to?

@autoboxer
Copy link
Contributor

thanks @alsoicode, the things I noticed were date formats not being respected in disabled fields, date formats not being configurable when filtering, date formats not being configurable for the list view, and an incorrect date being assigned with the 'today' button after a certain time. I need to create issues for a few, and honestly, I'm in a similar boat with having limited time, but why don't we connect either via email (mine is [email protected]), or via Slack and hopefully we can figure out time to collaborate. Thanks for the willingness to help, it's appreciated.

@alsoicode
Copy link
Contributor Author

Sure. My email is [email protected]. I've been using Keystone for quite a while, so it's nice to be able to give back.

@ytzvan
Copy link

ytzvan commented Dec 17, 2019

How did you fix this issue? Mine is giving 2 days back from the real date selected in form, and save into the db. In the Admin list and also Admin item the problem persist, I've tried hacky solutions like save the date in plain text and using moment.js with Keystone hooks but I'd like to come with a more clean solution. @alsoicode @autoboxer

@alsoicode
Copy link
Contributor Author

@ytzvan What version of Keystone 4 are you using? I'm using 4.2.1 for an older project and specifying utc: true on a Date type is working as expected for me.

@ytzvan
Copy link

ytzvan commented Dec 17, 2019

@alsoicode I'm using also Keystone 4.2.1, I just even change my PROD server timezone to use GMT instead of UTC, before the data shows 2 days earlier, now is only 1 day earlier, I'll check your suggest.
Thanks.

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

3 participants