Skip to content

Commit bddc928

Browse files
committed
Fix dostimestamp up
1 parent 6660dd7 commit bddc928

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

dissect/util/ts.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,10 @@ def uuid1timestamp(ts: int) -> datetime:
240240
def dostimestamp(ts: int, centiseconds: int = 0, swap: bool = False) -> datetime:
241241
"""Converts MS-DOS timestamps to naive datetime objects.
242242
243-
MS-DOS timestamps are recorded in local time, so we leave it up to the
244-
caller to add optional timezone information.
243+
MS-DOS timestamps are recorded in local time, so we leave it up to the caller to add optional timezone information.
245244
246-
According to http://www.vsft.com/hal/dostime.htm
245+
References:
246+
- https://web.archive.org/web/20180311003959/http://www.vsft.com/hal/dostime.htm
247247
248248
Args:
249249
ts: MS-DOS timestamp
@@ -280,8 +280,8 @@ def dostimestamp(ts: int, centiseconds: int = 0, swap: bool = False) -> datetime
280280

281281
return datetime( # noqa: DTZ001
282282
year,
283-
month,
284-
day,
283+
month or 1,
284+
day or 1,
285285
hours,
286286
minutes,
287287
seconds + extra_seconds,

tests/test_ts.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ def test_cocoatimestamp(imported_ts: ModuleType) -> None:
134134
assert imported_ts.cocoatimestamp(622894123.221783) == datetime(2020, 9, 27, 10, 8, 43, 221783, tzinfo=timezone.utc)
135135

136136

137+
def test_dostimestamp(imported_ts: ModuleType) -> None:
138+
assert imported_ts.dostimestamp(1391424892, 3) == datetime(2021, 7, 15, 14, 43, 56, 30000) # noqa: DTZ001
139+
assert imported_ts.dostimestamp(0) == datetime(1980, 1, 1, 0, 0) # noqa: DTZ001
140+
141+
137142
def test_negative_timestamps(imported_ts: ModuleType) -> None:
138143
# -5000.0 converted to a int representation
139144
assert imported_ts.oatimestamp(13885591609694748672) == datetime(1886, 4, 22, 0, 0, tzinfo=timezone.utc)

0 commit comments

Comments
 (0)