1.1 --- a/DateSupport.py Tue May 14 23:12:48 2013 +0200
1.2 +++ b/DateSupport.py Fri May 17 01:47:33 2013 +0200
1.3 @@ -6,6 +6,7 @@
1.4 @license: GNU GPL (v2 or later), see COPYING.txt for details.
1.5 """
1.6
1.7 +from email.utils import parsedate_tz
1.8 import calendar
1.9 import datetime
1.10 import re
1.11 @@ -593,9 +594,7 @@
1.12 dt = self.as_olson_datetime()
1.13 if dt:
1.14 seconds = dt.utcoffset().seconds + dt.utcoffset().days * 24 * 3600
1.15 - hours = abs(seconds) / 3600
1.16 - minutes = (abs(seconds) % 3600) / 60
1.17 - return sign(seconds) * hours, sign(seconds) * minutes
1.18 + return getHoursAndMinutes(seconds)
1.19
1.20 # Otherwise return None.
1.21
1.22 @@ -910,6 +909,24 @@
1.23 else:
1.24 return None
1.25
1.26 +def getDateTimeFromRFC2822(s):
1.27 +
1.28 + """
1.29 + Parse the RFC 2822 format datetime string 's', returning a datetime object.
1.30 + """
1.31 +
1.32 + data = parsedate_tz(s)
1.33 + offset = data[9]
1.34 + return DateTime(data[:6] + ("%02d:%02d" % getHoursAndMinutes(offset),))
1.35 +
1.36 +def getHoursAndMinutes(seconds):
1.37 +
1.38 + "Return an (hours, minutes) tuple for the given number of 'seconds'."
1.39 +
1.40 + hours = abs(seconds) / 3600
1.41 + minutes = (abs(seconds) % 3600) / 60
1.42 + return sign(seconds) * hours, sign(seconds) * minutes
1.43 +
1.44 def getDateStrings(s):
1.45
1.46 "Parse the string 's', extracting and returning all date strings."
2.1 --- a/README.txt Tue May 14 23:12:48 2013 +0200
2.2 +++ b/README.txt Fri May 17 01:47:33 2013 +0200
2.3 @@ -72,6 +72,7 @@
2.4 * Fixed the ISO 8601 representations of datetimes and added ISO 8601
2.5 datetime parsing support.
2.6 * Fixed the time zone information associated with page revisions.
2.7 + * Added RFC 2822 datetime parsing with help from the email.utils module.
2.8
2.9 New in MoinSupport 0.3 (Changes since MoinSupport 0.2)
2.10 ------------------------------------------------------