Python - How to get timezone from RSS feed

Viewed 3217

I need to get the published field of an RSS feed, and I need to know what the timezone is. I am storing the date in UTC, and I want another field to store the timezone so that I can later manipulate the datetime.

My current code is as follows:

for entry in feed['entries']:
    if hasattr(entry, 'published'):
        if isinstance(entry.published_parsed, struct_time):
            dt = datetime(*entry.published_parsed[:-3])

The final value of dt is the correct datetime in UTC, but I need also to get the original timezone. Can anyone help?

EDIT:

For future reference, even though it is not part of my original question, if you need to manipulate a non standard timezone (like est), you need to make a conversion table per your specification. Thanks to this answer: Parsing date/time string with timezone abbreviated name in Python?

1 Answers
Related