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

Activity timestamps are stored in local time instead of UTC #2882

Closed
Zharktas opened this issue Feb 22, 2016 · 4 comments · Fixed by #3240
Closed

Activity timestamps are stored in local time instead of UTC #2882

Zharktas opened this issue Feb 22, 2016 · 4 comments · Fixed by #3240
Assignees

Comments

@Zharktas
Copy link
Member

https://github.com/ckan/ckan/blob/master/ckan/model/activity.py#L41

If server has local time set to some timezone that differs from UTC, activity streams show -1 days ago instead of just now, since datetime.now() return local time instead of UTC. There probably are others as well which use local time instead of UTC, at least based on a quick search https://github.com/ckan/ckan/search?utf8=%E2%9C%93&q=datetime.now%28%29&type=Code

@wardi wardi self-assigned this Feb 23, 2016
@wardi
Copy link
Contributor

wardi commented Feb 23, 2016

That's not good.

A fix would include a migration that updates the times in the db (using the current time offset should be close enough for the activity stream) and updating the templates to use the snippet that adjusts the display to the client's time zone

Zharktas added a commit to vrk-kpa/api-catalog that referenced this issue Feb 24, 2016
@Zharktas
Copy link
Member Author

@wardi and apparently "-1 days ago" is returned from here https://github.com/ckan/ckan/blob/master/ckan/lib/formatters.py#L71 if server time is in UTC but ckan.display_timezone is something else like Europe/Helsinki

@framon
Copy link

framon commented Jun 1, 2016

I confirm that activity timestamps are always stored in server local timezone guessing it is UTC.

Given server timezone is America/Sao_Paulo (-03:00). When ckan.display_timezone is server then a difference of -6 hours is shown. When ckan.display_timezone is UTC then the difference becomes -3 hours (still incorrect).

@scardine
Copy link

scardine commented Aug 5, 2016

According to this ticket the issue may be more than 4 years old: http://trac.ckan.org/ticket/331.html

jrods added a commit to HighwayThree/ckan that referenced this issue Sep 8, 2016
bcgov/ckanext-bcgov#147 ckan#2882 ckan#2970

The Activity model now stores its timestamp in utc

In Formatters, localized_nice_date, removed the datetime replace method
calls with actually ensuring the comparing timestamps have a timezone
specified
jrods added a commit to HighwayThree/ckan that referenced this issue Sep 12, 2016
bcgov/ckanext-bcgov#147 ckan#2882 ckan#2970

The Activity model now stores its timestamp in utc

In Formatters, localized_nice_date, removed the datetime replace method
calls with actually ensuring the comparing timestamps have a timezone
specified

fixing typo
@jrods jrods mentioned this issue Sep 12, 2016
5 tasks
amercader pushed a commit that referenced this issue Feb 28, 2018
bcgov/ckanext-bcgov#147 #2882 #2970

The Activity model now stores its timestamp in utc

In Formatters, localized_nice_date, removed the datetime replace method
calls with actually ensuring the comparing timestamps have a timezone
specified

fixing typo
amercader pushed a commit that referenced this issue Feb 28, 2018
bcgov/ckanext-bcgov#147 #2882 #2970

The Activity model now stores its timestamp in utc

In Formatters, localized_nice_date, removed the datetime replace method
calls with actually ensuring the comparing timestamps have a timezone
specified

fixing typo
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

Successfully merging a pull request may close this issue.

5 participants