wintercms / winter

Free, open-source, self-hosted CMS platform based on the Laravel PHP Framework.
https://wintercms.com
MIT License
1.31k stars 188 forks source link

Correcting backend timestamps to use timezone preference #1111

Closed interworks-morr closed 2 months ago

interworks-morr commented 2 months ago

This corrects the timestamps on the backend to apply the timezone preference if set. The logic has been there, but it was the function wasn't being called.

This also adds a use statement for consistency with the other places the backend preference class is used.

LukeTowers commented 2 months ago

I'm going to close this for now, timestamp conversion happens on the client side; refer to https://github.com/wintercms/winter/blob/develop/modules/backend/assets/js/winter.datetime.js.

Let me know if there's still an issue that needs to be resolved.

mjauvin commented 2 months ago

@LukeTowers this looks valid to me, why are you closing this?

LukeTowers commented 2 months ago

Because it would break everything 😂

The Backend::dateTime() method returns a <time> element that the winter.datetime.js interacts with to display the correct timezone adjusted time for the user by making use of the <meta name="backend-timezone"> tag in the document's head.

The issue that the reporter had is that their timezone wasn't being applied to a particular time value being displayed, they were trying to fix it by forcing the Backend::dateTime() method to output a <time> element with the timezone already applied which would completely break every other use of that helper method as every timezone converted date would now be double converted (as the winter.datetime.js logic would assume that the value of the

The correct solution for the user's reported issue is to figure out why the specific time value they were having issues with wasn't being converted; not to break the conversion for every other part of the system.