Support #2628
closed[feed] Wrong dates / timezone mismatch in the feed regarding dates
0%
Description
Original source: https://rhodecode.tenderapp.com/help/discussions/questions/32206-two-different-dates-in-the-feeds
Goals:
- Find out why the dates are differnt
- Follow up with team/johbo to decide if further steps are needed.
Files
Updated by Anderson Santos over 9 years ago
- Status changed from New to In Progress
- Assignee set to Anderson Santos
Updated by Anderson Santos over 9 years ago
So the problem is the timezone difference, but something is wrong with all those settings because I can't get it to ever display a matching datetime, always displaying two hours of difference.
My local machine and my VM are in timezone Berlin, when displaying the datetime on Firefox feed, the dates are different as Firefox somehow tries to set a Timezone for the given date. The attached image explains the problem.
The code on the other hand have matching datetime and a Military style timezone description, which I believe is the root of the problem.
http://www.w3.org/Protocols/rfc822/#z28
I couldn't find anything on how to set the pubdate format of the feed classes Atom1Feed/Rss201rev2Feed.
A snippet from the feed source is:
Edited file new via RhodeCode Enterprise
2015-09-08T11:51:58Z
2015-09-08T11:51:58Z
RhodeCode Admin <anderson@rhodecode.com>
tag:172.16.115.152:5000,2015-09-08:/git-break-me/changeset/70a84438c293bb159679ced2ee4c199e7937a52aadmin (RhodeCode Admin) committed on Tue, 08 Sep 2015 11:51:58<br/>branch: master<br/>changeset: <a href="http://172.16.115.152:5000/git-break-me/changeset/70a84438c293bb159679ced2ee4c199e7937a52a">70a84438</a><pre>Edited file new via RhodeCode Enterprise
M new (1 lines added, 0 lines removed)</pre>
So as you can see, our webhelper feed generates the date format as:
@2015-09-08T11:51:58Z@
Supposedly feedgenerator has a function @ rfc2822_date@ but it doesn't explain how to use it with the generator class itself.
http://sluggo.scrapping.cc/python/WebHelpers/modules/feedgenerator.html
Updated by Anderson Santos over 9 years ago
I fixed it by forcing a local timezone
localtz = pytz.timezone('Europe/Berlin')
feed.add_item(title=h.shorter(commit.message, 160),
link=url('changeset_home', repo_name=repo_name,
revision=commit.raw_id, qualified=True),
author_name=commit.author,
description=''.join(self.__get_desc(commit)),
pubdate=localtz.localize(commit.date),
)
then it will display matching datetimes as the screenshot shows.
Also, adding to the conversation Marcin gave a link to an old bitbucket issue regarding the problem:
https://bitbucket.org/marcinkuzminski/rhodecode/issues/629/rss-feed-of-the-journal-reports-incorrect
Conclusion was to add timezone info to that date.
Just a technical note:
Trying to use pytz automatic localization didn't seem to do the trick. Using the code below it was still displaying GMT-0 instead of my VM timezone.
pubdate=pytz.utc.localize(commit.date)
So I guess the biggest issue here is how to identify which timezone Rhodecode has.
Updated by Anderson Santos over 9 years ago
- Related to Bug #2641: [rss, timezone] RSS feeds should use proper timezone-aware dates added
Updated by Anderson Santos over 9 years ago
- Status changed from In Progress to Resolved
Created a follow up ticket #2641 to implement the fix
Updated by Anderson Santos over 9 years ago
- Status changed from Resolved to Closed
Updated by Marcin Kuzminski [CTO] over 8 years ago
- Private changed from Yes to No