Skip to content

Commit e6e6172

Browse files
Fixed issue with null date for large values not having filetime
1 parent aadc8f5 commit e6e6172

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

extract_msg/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ def filetimeToDatetime(rawTime: int) -> datetime.datetime:
296296
from .null_date import NullDate
297297
date = NullDate(1970, 1, 1, 1)
298298
date += datetime.timedelta(seconds = filetimeToUtc(rawTime))
299+
date.filetime = rawTime
299300

300301
return date
301302
else:
@@ -304,7 +305,7 @@ def filetimeToDatetime(rawTime: int) -> datetime.datetime:
304305
# For TZError we just raise it again. It is a fatal error.
305306
raise
306307
except Exception:
307-
raise ValueError(f'Timestamp value of {filetimeToUtc(rawTime)} caused an exception. This was probably caused by the time stamp being too far in the future.')
308+
raise ValueError(f'Timestamp value of {filetimeToUtc(rawTime)} (raw: {rawTime}) caused an exception. This was probably caused by the time stamp being too far in the future.')
308309

309310

310311
def filetimeToUtc(inp: int) -> float:

extract_msg_tests/prop_tests.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,16 @@
197197
PropertyFlags.MANDATORY,
198198
NULL_DATE
199199
),
200+
(
201+
'Null Time 3',
202+
b'\x40\x00\x01\x02\x01\x00\x00\x00\x00\x3F\xDD\xA3\x57\x45\xB3\x0C',
203+
b'\x40\x00\x01\x02\x01\x00\x00\x00\x00\x3F\xDD\xA3\x57\x45\xB3\x0C',
204+
FixedLengthProp,
205+
'02010040',
206+
0x0040,
207+
PropertyFlags.MANDATORY,
208+
NULL_DATE
209+
),
200210
# Variable Length Props.
201211
(
202212
'Object',

0 commit comments

Comments
 (0)