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 after migration from Plone 4 to 5 #265

Open
agitator opened this issue Nov 13, 2017 · 7 comments
Open

Wrong time after migration from Plone 4 to 5 #265

agitator opened this issue Nov 13, 2017 · 7 comments

Comments

@agitator
Copy link
Member

On an Event that was created on Plone 4 before Summertime change, the time on the event was 8:30, on the migrated site the event time is shown as 7:30.

How did the datetime handling change from Plone 4 to 5?

@davisagli
Copy link
Member

Well, that involved the switch from ATContentTypes to plone.app.contenttypes and from DateTime to datetime. So, lots of change.

I remember fixing a bug like this long ago in ATEvent. Datetimes need to be rendered using the timezone offset they had on the date that is specified in the datetime value, not the offset on the day they are being rendered.

@agitator
Copy link
Member Author

It was already dexterity (p.a.contenttypes), if that narrows it down...?

@agitator
Copy link
Member Author

An old migrated event shows

(Pdb++) self.context.start
datetime.datetime(2017, 11, 22, 7, 30, tzinfo=<UTC>)

vs. a new created event

(Pdb++) self.context.start
datetime.datetime(2017, 11, 13, 15, 0, tzinfo=<DstTzInfo 'Europe/Zurich' CET+1:00:00 STD>)

What would a migration step look like and where should it go?

@davisagli
Copy link
Member

I'm not sure what change accounts for the difference then.

@jensens
Copy link
Member

jensens commented Nov 14, 2017

p.a.event in Plone 4 used to store the timezone in an extra field while having the datetime itself 'naive' (w/o timezone). This was a bad idea and involved tons of postprocessing when accessing the values.
In Plone 5 p.a.event stores the datetime with the correct timezone (non-naive) and theres no extra field for the timezone any longer.

It looks like while migration from 4 to 5 the timezone was dropped and set to UTC.

Solution: Write a script that iterates over all events, read start and end, check if timezone is UTC and if so, correct the timezone (and probably the hour) and write back.

@agitator
Copy link
Member Author

These are the values within the Plone4 site

ipdb> self.context.start
datetime.datetime(2017, 11, 22, 7, 30, tzinfo=<UTC>)
ipdb> self.context.end
datetime.datetime(2017, 11, 22, 14, 30, tzinfo=<UTC>)
ipdb> self.context.timezone
'Europe/Zurich'

@agitator
Copy link
Member Author

(Pdb++) import pytz
(Pdb++) tz = pytz.timezone('Europe/Zurich')
(Pdb++) tz
<DstTzInfo 'Europe/Zurich' BMT+0:30:00 STD>
(Pdb++) self.context.start.astimezone(tz=tz)
datetime.datetime(2017, 11, 22, 8, 30, tzinfo=<DstTzInfo 'Europe/Zurich' CET+1:00:00 STD>)

So the time format was still correct, but the displayed time is not correct.
If the timezone value stored on the object is different from the timezone within @@dateandtime-controlpanel should be converted for display, which is not happening right now.

@thet ?

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

No branches or pull requests

3 participants