22
33from datetime import datetime
44from collections import defaultdict
5- from sc2reader .constants import REGIONS , LOCALIZED_RACES
5+ from sc2reader .constants import REGIONS , LOCALIZED_RACES , GAME_SPEED_FACTOR
66from sc2reader .objects import Player , Observer , Team
77
88from sc2reader import utils
@@ -154,14 +154,6 @@ def load_details(self):
154154 if self .gateway == 'sg' :
155155 self .gateway = 'sea'
156156
157- if 'replay.details' in self .raw_data :
158- details = self .raw_data ['replay.details' ]
159- self .map = details .map
160- self .file_time = details .file_time
161- self .unix_timestamp = utils .windows_to_unix (self .file_time )
162- self .date = datetime .fromtimestamp (self .unix_timestamp )
163- self .utc_date = datetime .utcfromtimestamp (self .unix_timestamp )
164-
165157 if 'replay.attributes.events' in self .raw_data :
166158 # Organize the attribute data to be useful
167159 self .attributes = defaultdict (dict )
@@ -176,6 +168,22 @@ def load_details(self):
176168 self .is_ladder = (self .category == "Ladder" )
177169 self .is_private = (self .category == "Private" )
178170
171+ if 'replay.details' in self .raw_data :
172+ details = self .raw_data ['replay.details' ]
173+
174+ self .map = details .map
175+
176+ self .windows_timestamp = details .file_time - details .utc_adjustment
177+ self .unix_timestamp = utils .windows_to_unix (self .windows_timestamp )
178+ self .time_zone = details .utc_adjustment / (10 ** 7 * 60 * 60 )
179+
180+ self .end_time = datetime .utcfromtimestamp (self .unix_timestamp )
181+ self .game_length = self .length
182+ self .real_length = utils .Length (seconds = int (self .length .seconds / GAME_SPEED_FACTOR [self .speed ]))
183+ self .start_time = datetime .utcfromtimestamp (self .unix_timestamp - self .real_length .seconds )
184+ self .date = self .end_time #backwards compatibility
185+
186+
179187 def load_players (self ):
180188 #If we don't at least have details and attributes_events we can go no further
181189 if 'replay.details' not in self .raw_data :
0 commit comments