Skip to content

Commit 96ad23a

Browse files
committed
Improve the logic for handling timestamps.
1 parent b0b65cd commit 96ad23a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

sc2reader/resources.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,25 @@ def load_details(self):
274274

275275
self.map_name = details.map
276276

277+
# Keep this theory for now but it seems like it could be wrong
277278
if details.os == 0:
278279
self.os = "Windows"
280+
elif details.os == 1:
281+
self.os = "Mac"
282+
else:
283+
raise ValueError("Unknown operating system {} detected.".format(details.os))
284+
285+
# can't find a flag for this so just check to see which is greater
286+
if details.file_time > details.utc_adjustment:
279287
self.windows_timestamp = details.file_time-details.utc_adjustment
280288
self.unix_timestamp = utils.windows_to_unix(self.windows_timestamp)
281289
self.time_zone = details.utc_adjustment/(10**7*60*60)
282290
self.end_time = datetime.utcfromtimestamp(self.unix_timestamp)
283-
elif details.os == 1:
284-
self.os = "Mac"
291+
else:
285292
self.windows_timestamp = details.utc_adjustment
286293
self.unix_timestamp = utils.windows_to_unix(self.windows_timestamp)
287294
self.time_zone = (details.utc_adjustment-details.file_time)/(10**7*60*60)
288295
self.end_time = datetime.utcfromtimestamp(self.unix_timestamp)
289-
else:
290-
raise ValueError("Unknown operating system {} detected.".format(details.os))
291296

292297
self.game_length = self.length
293298
self.real_length = utils.Length(seconds=int(self.length.seconds/GAME_SPEED_FACTOR[self.speed]))

0 commit comments

Comments
 (0)