1414
1515from string import digits
1616import time
17+ import calendar
1718import os
1819
1920__all__ = ('get_object_type_by_name' , 'parse_date' , 'parse_actor_and_date' ,
@@ -106,9 +107,10 @@ def parse_date(string_date):
106107 * ISO 8601 2005-04-07T22:13:13
107108 The T can be a space as well
108109
109- :return: Tuple(int(timestamp ), int(offset)), both in seconds since epoch
110+ :return: Tuple(int(timestamp_UTC ), int(offset)), both in seconds since epoch
110111 :raise ValueError: If the format could not be understood
111- :note: Date can also be YYYY.MM.DD, MM/DD/YYYY and DD.MM.YYYY"""
112+ :note: Date can also be YYYY.MM.DD, MM/DD/YYYY and DD.MM.YYYY.
113+ """
112114 # git time
113115 try :
114116 if string_date .count (' ' ) == 1 and string_date .rfind (':' ) == - 1 :
@@ -121,6 +123,7 @@ def parse_date(string_date):
121123 offset = verify_utctz (string_date [- 5 :])
122124 string_date = string_date [:- 6 ] # skip space as well
123125 # END split timezone info
126+ offset = utctz_to_altz (offset )
124127
125128 # now figure out the date and time portion - split time
126129 date_formats = list ()
@@ -153,13 +156,10 @@ def parse_date(string_date):
153156 for fmt in date_formats :
154157 try :
155158 dtstruct = time .strptime (date_part , fmt )
156- fstruct = time . struct_time ((dtstruct .tm_year , dtstruct .tm_mon , dtstruct .tm_mday ,
159+ utctime = calendar . timegm ((dtstruct .tm_year , dtstruct .tm_mon , dtstruct .tm_mday ,
157160 tstruct .tm_hour , tstruct .tm_min , tstruct .tm_sec ,
158161 dtstruct .tm_wday , dtstruct .tm_yday , tstruct .tm_isdst ))
159- utctime = time .mktime (fstruct )
160- # time.mktime returns local time, so we need to adjust it for local offset
161- utctime -= time .altzone if time .daylight else time .timezone
162- return int (utctime ), utctz_to_altz (offset )
162+ return int (utctime ), offset
163163 except ValueError :
164164 continue
165165 # END exception handling
0 commit comments