Skip to content

Commit d47e30d

Browse files
committed
Attempt 2 at fixing file times for all possible replays.
1 parent b751dfe commit d47e30d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

sc2reader/resources.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,19 @@ def load_details(self):
282282
else:
283283
raise ValueError("Unknown operating system {} detected.".format(details.os))
284284

285-
# can't find a flag for this so just check to see which is greater
286-
if details.file_time > details.utc_adjustment:
285+
# If the utc_adjustment is really an adjustment it's magnitude will be
286+
# less than 24 hours in the unit of 1/10**7 of a second. Negative values
287+
# must always be adjustments
288+
if details.utc_adjustment < 10**7*60*60*24:
287289
self.windows_timestamp = details.file_time-details.utc_adjustment
288290
self.unix_timestamp = utils.windows_to_unix(self.windows_timestamp)
289291
self.time_zone = details.utc_adjustment/(10**7*60*60)
290292
self.end_time = datetime.utcfromtimestamp(self.unix_timestamp)
293+
294+
# Otherwise the utc_adjustment is the windows timestamp of the local time
295+
# And the file_time is the windows timestamp of the utc time.
291296
else:
292-
self.windows_timestamp = details.utc_adjustment
297+
self.windows_timestamp = details.file_time
293298
self.unix_timestamp = utils.windows_to_unix(self.windows_timestamp)
294299
self.time_zone = (details.utc_adjustment-details.file_time)/(10**7*60*60)
295300
self.end_time = datetime.utcfromtimestamp(self.unix_timestamp)

0 commit comments

Comments
 (0)