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

Daylight savings? #160

Closed
jrmlhermitte opened this issue Mar 5, 2019 · 5 comments
Closed

Daylight savings? #160

jrmlhermitte opened this issue Mar 5, 2019 · 5 comments

Comments

@jrmlhermitte
Copy link

jrmlhermitte commented Mar 5, 2019

It seems feedparser might be interpreting daylight savings incorrectly:

data = """<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>ARTS &amp;amp; CULTURE - Los Angeles Times</title>
    <link>http://www.latimes.com/entertainment/arts/rss2.0.xml</link>
    <description>The best of arts and culture news from L.A. Times columnists and critics. Read reviews and find event information for Los Angeles.</description>
    <language>en-US</language>
    <copyright>&#xA9;2019 Los Angeles Times</copyright>
    <lastBuildDate>Mon, 4 Mar 2019 11:19:15 -0800</lastBuildDate>
    <item>
    <title>(With pub date during DST) For the cult of Sondheim, &apos;Merrily We Roll Along,&apos; and on, and on, and ...</title>
	<dc:creator>Stuart Emmrich</dc:creator>
	<link>http://www.latimes.com/entertainment/arts/la-et-cm-merrily-we-roll-along-20190304-story.html</link>
	<description><![CDATA[
	  <p>In fall 1981, the most anticipated new musical of the Broadway season was an adaptation of the 1934 Kaufman and Hart play “Merrily We Roll Along,” with lyrics and music by Stephen Sondheim, a book by a George Furth and direction by Hal Prince.</p> <p>The musical tells the story of three young characters...</p>
	]]></description>
	<pubDate>Mon, 4 Jul 2019 04:00:00 PST</pubDate>
<media:content url="http://www.trbimg.com/img-5c7c2121/turbine/la-1551638807-umw4chssva-snap-image" type="image/jpeg">
    <media:description type="plain"><![CDATA[&quot;Merrily We Roll Along&quot; director Noah Brody, far left, with cast members, foreground from left, Jessie Austrian, Ben Steinfeld, Paul Coffey and Brittany Bradford; in the back, Manu Narayan and Emily Young.]]></media:description><media:credit role="author" scheme="urn:ebu"><![CDATA[Jennifer S. Altman / For The Times]]></media:credit></media:content>
</item>
</channel> 
</rss>
"""
import feedparser
feed_data = feedparser.parse(data)
feed_entry = feed_data['entries'][0]

For this data, I get:

feed_entry['published'] :Mon, 4 Jul 2019 04:00:00 PST

feed_entry['published_parsed']: time.struct_time(tm_year=2019, tm_mon=7, tm_mday=4, tm_hour=12, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=185, tm_isdst=0)

This should be tm_isdst=1 not tm_isdst=0.

screen shot 2019-03-05 at 11 16 09 am

Am I seeing things correctly? Is Daylight savings properly treated here or has it not been considered yet? I may be able to help contribute. thanks!

@kurtmckee
Copy link
Owner

kurtmckee commented Mar 5, 2019 via email

@jrmlhermitte
Copy link
Author

Thanks for the quick response!

feedparser's date parsers normalize everything to UTC so that there is no DST consideration.

So then should the example above should have normalized to tm_hour=11 not 12?

@kurtmckee
Copy link
Owner

kurtmckee commented Mar 5, 2019 via email

@jrmlhermitte
Copy link
Author

Ah indeed. Thanks for the clarification. I assumed PST referred to both with and without daylight savings, and that figuring out if the date is in daylight savings was left to interpreting the day and month. This closes my issue.
If you could add a note about this in the docstring (just an example comparing PST and PDT for example here that would be great.

Thanks again for the quick response and very useful library.

@kurtmckee
Copy link
Owner

That's a good suggestion! Thanks!

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

No branches or pull requests

2 participants