changeset 95:ed075d8d26ac

Correct for local daylight savings.
author Martin Geisler <mg@daimi.au.dk>
date Tue, 11 Mar 2008 11:46:23 +0100
parents 2ffbabd435e9
children 6b27d51103a4
files update_news.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/update_news.py	Tue Mar 11 11:01:42 2008 +0100
+++ b/update_news.py	Tue Mar 11 11:46:23 2008 +0100
@@ -66,7 +66,11 @@
               (60, 'minutes'),
               (1, 'seconds')]
 
-    difference = time() - timegm(time_tuple)
+    # Correction for daylight saving. Feedparser seems to return a
+    # struct_time with the tm_isdst flag set to 1 if local daylight
+    # savings is in effect. This hopefully corrects this extra offset.
+    daylight_offset = time_tuple[8] * 3600
+    difference = time() - (timegm(time_tuple) - daylight_offset)
     for delta, text in deltas:
         if difference > 2*delta:
             break