Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ exclude .gitignore
exclude *.pyc
recursive-include config *
recursive-exclude dfdatetime *.pyc
# The test scripts are not required in a binary distribution package they
# The test scripts are not required in a binary distribution package they
# are considered source distribution files and excluded by find_package().
recursive-include tests *.py
4 changes: 2 additions & 2 deletions config/dpkg/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dfdatetime (20260507-1) unstable; urgency=low
dfdatetime (20260513-1) unstable; urgency=low

* Auto-generated

-- Log2Timeline maintainers <log2timeline-maintainers@googlegroups.com> Thu, 07 May 2026 05:21:30 +0200
-- Log2Timeline maintainers <log2timeline-maintainers@googlegroups.com> Wed, 13 May 2026 17:16:59 +0200
2 changes: 1 addition & 1 deletion dfdatetime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
from dfdatetime import webkit_time


__version__ = '20260507'
__version__ = '20260513'
3 changes: 3 additions & 0 deletions dfdatetime/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ def ConvertJSONToDateTimeValues(cls, json_dict):

Returns:
dfdatetime.DateTimeValues: date and time values.

Raises:
KeyError: If date and time values type is not supported by factory.
"""
class_name = json_dict.get('__class_name__')
if class_name:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "dfdatetime"
version = "20260507"
version = "20260513"
description = "Digital Forensics date and time (dfDateTime)"
maintainers = [
{ name = "Log2Timeline maintainers", email = "log2timeline-maintainers@googlegroups.com" },
Expand Down
5 changes: 5 additions & 0 deletions tests/apfs_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def testCopyFromDateTimeString(self):

def testCopyToDateTimeString(self):
"""Tests the CopyToDateTimeString function."""
apfs_time_object = apfs_time.APFSTime(timestamp=1281643591987654321)

date_time_string = apfs_time_object.CopyToDateTimeString()
self.assertEqual(date_time_string, '2010-08-12 20:06:31.987654321')

apfs_time_object = apfs_time.APFSTime(timestamp=9223372036854775810)

date_time_string = apfs_time_object.CopyToDateTimeString()
Expand Down
44 changes: 44 additions & 0 deletions tests/decorators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
"""Tests for the decorators."""

import unittest
import warnings

from dfdatetime import decorators


class TestClass:
"""Class for testing deprecated decorator."""

def Method(self):
"""Test method."""
return 'result'

@decorators.deprecated
def DeprecatedMethod(self):
"""Deprecated test method."""
return 'deprecated_result'


class DeprecatedTest(unittest.TestCase):
"""Tests for the deprecated decorator."""

def test_deprecated(self):
"""Tests the deprecated decorator."""
test_object = TestClass()

result = test_object.Method()
self.assertEqual(result, 'result')

with warnings.catch_warnings(record=True) as warning:
warnings.simplefilter('always', DeprecationWarning)

result = test_object.DeprecatedMethod()

self.assertEqual(result, 'deprecated_result')
self.assertEqual(len(warning), 1)
self.assertIn('DeprecatedMethod', str(warning[0].message))


if __name__ == '__main__':
unittest.main()
13 changes: 13 additions & 0 deletions tests/dotnet_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ def testCopyToDateTimeString(self):
dotnet_date_string = dotnet_date_time.CopyToDateTimeString()
self.assertEqual(dotnet_date_string, '2020-12-12 12:12:12.1230000')

# Test out of range timestamp
dotnet_date_time = dotnet_datetime.DotNetDateTime(timestamp=-1)
self.assertIsNone(dotnet_date_time.CopyToDateTimeString())

dotnet_date_time = dotnet_datetime.DotNetDateTime(
timestamp=dotnet_datetime.DotNetDateTime._UINT64_MAX + 1)
self.assertIsNone(dotnet_date_time.CopyToDateTimeString())

# Test year > 9999
dotnet_date_time = dotnet_datetime.DotNetDateTime()
with self.assertRaises(ValueError):
dotnet_date_time.CopyFromDateTimeString('10000-01-01')


if __name__ == '__main__':
unittest.main()
3 changes: 3 additions & 0 deletions tests/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def testDateTimeValuesRegistration(self):
len(factory.Factory._date_time_values_types),
number_of_date_time_values_types)

with self.assertRaises(KeyError):
factory.Factory.DeregisterDateTimeValues(TestDateTimeValues)

def testNewDateTimeValues(self):
"""Tests the NewDateTimeValues function."""
test_date_time_values = factory.Factory.NewDateTimeValues(
Expand Down
11 changes: 11 additions & 0 deletions tests/golang_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ def testGetNumberOfSeconds(self):
golang_timestamp = bytes.fromhex('ff0000000000000000000000000000')
golang_time_object._GetNumberOfSeconds(golang_timestamp)

with self.assertRaises(ValueError):
golang_timestamp = bytes.fromhex('ffffffffffffffffffffffffffff01')
golang_time_object._GetNumberOfSeconds(golang_timestamp)

def testCopyFromDateTimeString(self):
"""Tests the CopyFromDateTimeString function."""
golang_time_object = golang_time.GolangTime()
Expand Down Expand Up @@ -170,6 +174,9 @@ def testCopyFromDateTimeString(self):
self.assertEqual(golang_time_object._nanoseconds, 567890000)
self.assertEqual(golang_time_object._time_zone_offset, 60)

with self.assertRaises(ValueError):
golang_time_object.CopyFromDateTimeString('-0001-01-01')

def testCopyToDateTimeString(self):
"""Test the CopyToDateTimeString function."""
golang_timestamp = bytes.fromhex('010000000eafffe8d121d95050ffff')
Expand All @@ -194,6 +201,10 @@ def testCopyToDateTimeString(self):
date_time_string = golang_time_object.CopyToDateTimeString()
self.assertEqual(date_time_string, '2000-01-01 12:23:45.000056789')

golang_time_object = golang_time.GolangTime()
date_time_string = golang_time_object.CopyToDateTimeString()
self.assertIsNone(date_time_string)


if __name__ == '__main__':
unittest.main()
4 changes: 4 additions & 0 deletions tests/rfc2579_date_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def testInitialize(self):
self.assertEqual(rfc2579_date_time_object.deciseconds, 6)
self.assertEqual(rfc2579_date_time_object.time_zone_offset, 120)

rfc2579_date_time_object = rfc2579_date_time.RFC2579DateTime(
rfc2579_date_time_tuple=(2010, 8, 12, 20, 6, 31, 6, '-', 2, 0))
self.assertEqual(rfc2579_date_time_object.time_zone_offset, -120)

with self.assertRaises(ValueError):
rfc2579_date_time.RFC2579DateTime(
rfc2579_date_time_tuple=(2010, 8, 12, 20, 6, 31))
Expand Down
26 changes: 26 additions & 0 deletions tests/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@
class SerializerTest(unittest.TestCase):
"""Tests for the date and time values serializer."""

def testConvertDictToDateTimeValues(self):
"""Test ConvertDictToDateTimeValues function."""
json_dict = {
'__class_name__': 'PosixTime',
'__type__': 'DateTimeValues',
'timestamp': 1281643591}

date_time_object = serializer.Serializer.ConvertDictToDateTimeValues(
json_dict)
self.assertIsNotNone(date_time_object)

def testConvertDateTimeValuesToDict(self):
"""Test ConvertDateTimeValuesToDict function."""
posix_time_object = posix_time.PosixTime(timestamp=1281643591)
json_dict = serializer.Serializer.ConvertDateTimeValuesToDict(
posix_time_object)
self.assertIsNotNone(json_dict)

with self.assertRaises(TypeError):
serializer.Serializer.ConvertDateTimeValuesToDict('not a datetime')

def testConvertDateTimeValuesToJSON(self):
"""Test ConvertDateTimeValuesToJSON function."""
posix_time_object = posix_time.PosixTime(timestamp=1281643591)
Expand Down Expand Up @@ -317,6 +338,11 @@ def testConvertJSONToDateTimeValues(self):
json_dict)
self.assertEqual(date_time_object, expected_date_time_object)

with self.assertRaises(KeyError):
json_dict = {
'__class_name__': 'UnknownType', '__type__': 'DateTimeValues'}
serializer.Serializer.ConvertJSONToDateTimeValues(json_dict)


if __name__ == '__main__':
unittest.main()
Loading