Skip to content

Commit f2bbbea

Browse files
Adds support for datetime
1 parent fe5529c commit f2bbbea

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

EntityHash/EntiryHash.py

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import struct
77
from pathlib import Path
88
from typing import Any
9+
import datetime as dt
910

1011
import numpy as np
1112
from pydantic import BaseModel
@@ -109,6 +110,10 @@ def add_thing_to_hash(sha256, value: Any):
109110
sha256.update(struct.pack("q", value))
110111
elif isinstance(value, bytes):
111112
sha256.update(value)
113+
elif isinstance(value, dt.timedelta):
114+
add_thing_to_hash(sha256, value.total_seconds())
115+
elif isinstance(value, dt.datetime):
116+
add_thing_to_hash(sha256, value.isoformat())
112117
elif (
113118
inspect.ismodule(value)
114119
or inspect.isclass(value)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "EntityHash"
3-
version = "1.2.2"
3+
version = "1.3.0"
44
description = "Library that unifies interface for hash calculation and representation"
55
authors = ["Adam Ryczkowski <[email protected]>"]
66
readme = "README.adoc"

0 commit comments

Comments
 (0)