- Add support for `dataclass`es with `datetime` fields.
- They are expected to be encoded as a UTC timestamp, int or float in the source dictionaries.
- Add a helper function for serializing `dataclass`es with `datetime` fields
Example:
python3
from datetime import datetime
from dataclasses import dataclass
from dictaclass import dataclass_to_dict, json_dumps_default, to_dataclass
import json
dataclass(frozen=True)
class ExampleDC:
timestamp: datetime
dc = ExampleDC(datetime.now())
dc_json = json.dumps(dataclass_to_dict(dc), default=json_dumps_default)
print(dc_json)
Output: