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

Wrong Time displayed in DateTimeWidget #2597

Open
jackahl opened this issue Aug 2, 2021 · 4 comments · May be fixed by plone/plone.restapi#1192
Open

Wrong Time displayed in DateTimeWidget #2597

jackahl opened this issue Aug 2, 2021 · 4 comments · May be fixed by plone/plone.restapi#1192

Comments

@jackahl
Copy link
Sponsor Member

jackahl commented Aug 2, 2021

Describe the bug
The wrong time is displayed in the effective date field after a document has been published.

To Reproduce
Steps to reproduce the behavior:

  1. Go to volto.kitconcept.com/
  2. Create a new page
  3. Publich the new page
  4. go back to editing the new page
    -> Effective Date Time in Sidebar is not your local time

Expected behavior
Time in Effective Date field in the edit sidebar should correspond with your local time

Screenshots
Screenshot 2021-08-02 at 11-27-51 Edit Page

Actual local time of publishment was 10:41

Software (please complete the following information):

  • OS: Ubuntu 20.08
  • Browser: Firefox 90.0 (64-bit)
  • Volto 13.1.2
  • Plone 5.2.4

Additional context
The correct time seems to be saved in Plone, but the parsing it back in the frontend seems to go wrong. I suspect the problem to occur either in:

export const parseDateTime = (locale, value, format) => {

or with the rc-time-picker itself

@jackahl
Copy link
Sponsor Member Author

jackahl commented Aug 2, 2021

@nzambello could you have a look here please? It seems this might have something to do with your code from: https://github.com/plone/volto/blob/master/src/helpers/Utils/Utils.js#L155

@jackahl
Copy link
Sponsor Member Author

jackahl commented Aug 2, 2021

I did some further research and it might actually be a problem with Plone REST API. checking the returned value for "effective" on an item published at 2021-08-02T12:47:15 GMT+2 (German local time) returns an effective date of "2021-08-02T12:47:15" without any Timezone reference.
While the created field has "2021-08-02T10:47:09+00:00". So that field seems to get normalized to GMT while the "effective field does not.
So @nzambello probably nothing wrong with your parseDateTime function, but a problem in p.restapi

@jackahl
Copy link
Sponsor Member Author

jackahl commented Aug 2, 2021

@buchi I saw you implemented some stuff regarding DateTime in p.restapi. This comment seems to sum up the issue we are having: https://github.com/plone/plone.restapi/blob/02421afe76b53414ee569bb42077248b45d6e8e8/src/plone/restapi/deserializer/dxfields.py#L96

Can you maybe explain why this is? Looking at the portal_catalog the time zone information we need is stored in the object:
Screenshot 2021-08-02 at 13-59-27 Indexes all content in the site

@cekk
Copy link
Member

cekk commented Aug 9, 2021

As metioned by @nzambello i could have found a possible solution.

The problem is that for effective and expires there are custom field setter and getter that strips timezone infos for some reasons related to z3cform widgets i think.

The problem is that when Volto post that date, it is a UTC string.
Then restapi deserializer takes it and convert it to a datetime object with right timezone but not "localized" (so the hour is still the UTC one).
After that, the date is passed to field's setter, that takes the date items (day, month, year, hour, minutes) and ignore the timezone info, so the date will be saved with a wrong hour.

With my patch i simply "localize" the date in deserializer to be able to pass the correct hour to the setter.

I don't know if this could be a good solution to be moved into plone.restapi (i made these changes only for these two fields).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants