[Django] #26653: Syndication's lastBuildDate is not timezone aware.

55 views
Skip to first unread message

Django

unread,
May 23, 2016, 5:50:30 AM5/23/16
to django-...@googlegroups.com
#26653: Syndication's lastBuildDate is not timezone aware.
--------------------------+------------------------------------------------
Reporter: didrix | Owner: nobody
Type: Bug | Status: new
Component: | Version: 1.9
contrib.syndication |
Severity: Normal | Keywords: timezone syndication lastBuildDate
Triage Stage: | Has patch: 0
Unreviewed |
Easy pickings: 0 | UI/UX: 0
--------------------------+------------------------------------------------
The lastBuildDate element in an RSS feed is not timezone aware. For
instance on a non-utc timezone ('Europe/Amsterdam') it will generate a
response with
{{{
<lastBuildDate>Mon, 23 May 2016 11:36:39 -0000</lastBuildDate>
}}}
while it should be
{{{
<lastBuildDate>Mon, 23 May 2016 11:36:39 +0200</lastBuildDate>
}}}

relevant files:
django/utils/feedgenerator.py

Seen in version 1.9.6 and 1.10a1, probably more versions affected.
pytz._version_ = 2016.4

--
Ticket URL: <https://code.djangoproject.com/ticket/26653>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 23, 2016, 11:19:32 AM5/23/16
to django-...@googlegroups.com
#26653: Make syndication's lastBuildDate timezone aware
-------------------------------------+-------------------------------------
Reporter: didrix | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.syndication | Version: 1.9
Severity: Normal | Resolution:
Keywords: timezone | Triage Stage: Accepted
syndication lastBuildDate |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 1
* easy: 0 => 1
* needs_docs: => 0
* has_patch: 0 => 1
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

I guess a patch might look like:
{{{ #!diff
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
index 3a91af3..2bbc7b8 100644
--- a/django/utils/feedgenerator.py
+++ b/django/utils/feedgenerator.py
@@ -26,7 +26,7 @@ from __future__ import unicode_literals
import datetime
import warnings

-from django.utils import datetime_safe, six
+from django.utils import datetime_safe, six, timezone
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text, iri_to_uri
from django.utils.six import StringIO
@@ -223,7 +223,7 @@ class SyndicationFeed(object):
if latest_date is None or item_date > latest_date:
latest_date = item_date

- return latest_date or datetime.datetime.now()
+ return latest_date or timezone.now()


class Enclosure(object):
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26653#comment:1>

Django

unread,
May 24, 2016, 6:38:26 AM5/24/16
to django-...@googlegroups.com
#26653: Make syndication's lastBuildDate timezone aware
-------------------------------------+-------------------------------------
Reporter: didrix | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: contrib.syndication | Version: 1.9
Severity: Normal | Resolution:
Keywords: timezone | Triage Stage: Accepted
syndication lastBuildDate |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by didrix):

Replying to [comment:1 timgraham]:


> I guess a patch might look like:
> {{{ #!diff
> diff --git a/django/utils/feedgenerator.py
b/django/utils/feedgenerator.py
> index 3a91af3..2bbc7b8 100644
> --- a/django/utils/feedgenerator.py
> +++ b/django/utils/feedgenerator.py

> @@ -226,7 +226,7 @@ class SyndicationFeed(object):


> - return latest_date or datetime.datetime.now()
> + return latest_date or timezone.now()
> }}}

Could also do this:

{{{ #!diff
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
index 3a91af3..2bbc7b8 100644
--- a/django/utils/feedgenerator.py
+++ b/django/utils/feedgenerator.py

@@ -226,7 +226,7 @@ class SyndicationFeed(object):


- return latest_date or datetime.datetime.now()

+ return latest_date or timezone.localtime(timezone.now())
}}}

What do you reckon?

--
Ticket URL: <https://code.djangoproject.com/ticket/26653#comment:2>

Django

unread,
May 24, 2016, 7:12:28 AM5/24/16
to django-...@googlegroups.com
#26653: Make syndication's lastBuildDate timezone aware
-------------------------------------+-------------------------------------
Reporter: didrix | Owner: nobody

Type: | Status: new
Cleanup/optimization |
Component: contrib.syndication | Version: 1.9
Severity: Normal | Resolution:
Keywords: timezone | Triage Stage: Accepted
syndication lastBuildDate |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by aaugustin):

Let's use UTC.

--
Ticket URL: <https://code.djangoproject.com/ticket/26653#comment:3>

Django

unread,
May 24, 2016, 11:01:12 AM5/24/16
to django-...@googlegroups.com
#26653: Make syndication's lastBuildDate timezone aware
-------------------------------------+-------------------------------------
Reporter: didrix | Owner:
Type: | ketanbhatt
Cleanup/optimization | Status: assigned

Component: contrib.syndication | Version: 1.9
Severity: Normal | Resolution:
Keywords: timezone | Triage Stage: Accepted
syndication lastBuildDate |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by ketanbhatt):

* status: new => assigned
* owner: nobody => ketanbhatt


--
Ticket URL: <https://code.djangoproject.com/ticket/26653#comment:4>

Django

unread,
May 24, 2016, 12:55:32 PM5/24/16
to django-...@googlegroups.com
#26653: Make syndication's lastBuildDate timezone aware
-------------------------------------+-------------------------------------
Reporter: didrix | Owner:
Type: | ketanbhatt
Cleanup/optimization | Status: assigned
Component: contrib.syndication | Version: 1.9
Severity: Normal | Resolution:
Keywords: timezone | Triage Stage: Accepted
syndication lastBuildDate |
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by ketanbhatt):

Hey,

This is the first time I am contributing to Django, so please help me if I
do some mistakes.

I followed the steps from this guideline
https://docs.djangoproject.com/en/1.9/internals/contributing/writing-code
/working-with-git/

Here is the link to the branch I have done my changes on:
https://github.com/ketanbhatt/django/tree/ticket_26653

And here is a diff of the master and my branch:
https://github.com/django/django/compare/master...ketanbhatt:ticket_26653?expand=1

Please take a look and let me know the next steps.

Thank you

--
Ticket URL: <https://code.djangoproject.com/ticket/26653#comment:5>

Django

unread,
May 28, 2016, 10:25:01 PM5/28/16
to django-...@googlegroups.com
#26653: Make syndication's lastBuildDate timezone aware
-------------------------------------+-------------------------------------
Reporter: didrix | Owner:
Type: | ketanbhatt
Cleanup/optimization | Status: assigned
Component: contrib.syndication | Version: 1.9
Severity: Normal | Resolution:
Keywords: timezone | Triage Stage: Accepted
syndication lastBuildDate |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by berkerpeksag):

* cc: berker.peksag@… (added)
* needs_better_patch: 0 => 1
* needs_tests: 1 => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/26653#comment:6>

Django

unread,
May 29, 2016, 1:08:56 PM5/29/16
to django-...@googlegroups.com
#26653: Make syndication's lastBuildDate timezone aware
-------------------------------------+-------------------------------------
Reporter: didrix | Owner:
Type: | ketanbhatt
Cleanup/optimization | Status: assigned
Component: contrib.syndication | Version: 1.9
Severity: Normal | Resolution:
Keywords: timezone | Triage Stage: Ready for
syndication lastBuildDate | checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by berkerpeksag):

* needs_better_patch: 1 => 0
* stage: Accepted => Ready for checkin


Comment:

[https://github.com/django/django/pull/6648 PR #6648] looks good to me.

--
Ticket URL: <https://code.djangoproject.com/ticket/26653#comment:7>

Django

unread,
May 30, 2016, 6:36:42 PM5/30/16
to django-...@googlegroups.com
#26653: Make syndication's lastBuildDate timezone aware
-------------------------------------+-------------------------------------
Reporter: didrix | Owner:
Type: | ketanbhatt
Cleanup/optimization | Status: closed
Component: contrib.syndication | Version: 1.9
Severity: Normal | Resolution: fixed

Keywords: timezone | Triage Stage: Ready for
syndication lastBuildDate | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"f31fbbae1ab1572e1637fc5ca9ae4bae66679294" f31fbba]:
{{{
#!CommitTicketReference repository=""
revision="f31fbbae1ab1572e1637fc5ca9ae4bae66679294"
Fixed #26653 -- Made SyndicationFeed.latest_post_date() return time in
UTC.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26653#comment:8>

Django

unread,
May 30, 2016, 7:32:34 PM5/30/16
to django-...@googlegroups.com
#26653: Make syndication's lastBuildDate timezone aware
-------------------------------------+-------------------------------------
Reporter: didrix | Owner:
Type: | ketanbhatt
Cleanup/optimization | Status: closed
Component: contrib.syndication | Version: 1.9
Severity: Normal | Resolution: fixed
Keywords: timezone | Triage Stage: Ready for
syndication lastBuildDate | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"37aec6b186941566a664369e031d72b2ddd204fc" 37aec6b1]:
{{{
#!CommitTicketReference repository=""
revision="37aec6b186941566a664369e031d72b2ddd204fc"
Refs #26653 -- Fixed a feedgenerator test that requires a database query
on PostgreSQL.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26653#comment:9>

Reply all
Reply to author
Forward
0 new messages