DanDiplo / Umbraco.AuditLogViewer

An audit and content log table viewer for Umbraco CMS
https://www.diplo.co.uk/blog/web-development/diplo-audit-log-viewer-for-umbraco-10/
16 stars 7 forks source link

Problems with dates #2

Closed vonbarnekowa closed 5 years ago

vonbarnekowa commented 5 years ago

Dates are written in UTC+2. It would be nice if it changes according to the server time.

DanDiplo commented 5 years ago

Hi. What culture settings do you have in your installation? In my tests the date reflects the server time. Do you have any more info about your setup that might help? Are you able to compare the dates to those that come out of the umbracoLog table, as that is the source of the data? Thanks!

vonbarnekowa commented 5 years ago

My server timezone is Zürich, Zurich, Switzerland (UTC+1). When I go to the "History" section of a node, the time is correct. It's only in the plugin where the time is in advance. What seems strange, is that it worked before the time change last Sunday.

See here it's correct: screen shot 2018-10-31 at 08 33 59

And via the plugin, it's wrong: screen shot 2018-10-31 at 08 33 55

Here the row in the database: screen shot 2018-10-31 at 08 35 49

DanDiplo commented 5 years ago

Hi. So I looked into this more. As you may know Umbraco uses AngularJS framework in the back-office. There is a known issue with Angular formatting dates. So simply by formatting the date using Angular's built-in formatter it changes the timezone. Unfortunately Umbraco still uses an old version of Angular, so there is no built-in workaround in Angular.

Note that if you click into an item to view a log entry detail you can see the "correct" raw date shown underneath the heading in pale text (this doesn't use any Angular formatting).

image

I looked at the Umbraco source to see how they deal with it. Basically they have written their own date helper and formatter that deals with formatting based on the current user's timezone:

https://github.com/umbraco/Umbraco-CMS/blob/c021cc50ce8532acdd22720753d979b4d5f8e05c/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbcontentnodeinfo.directive.js#L103

I could apply this function, but I'll need to work out which version of Umbraco this was added in and then look at putting it in the next release.

DanDiplo commented 5 years ago

I've uploaded a new version (1.0.4) that should fix the UTC date issue:

Nuget: https://www.nuget.org/packages/Diplo.AuditLogViewer/1.0.4

Our: https://our.umbraco.com/packages/developer-tools/diplo-audit-log-viewer/

Let me know if this fixes your issue.

vonbarnekowa commented 5 years ago

Will install your fix in our dev environment and give you a feedback. I close this issue temporarily.