capturegraph.data.typed_json.handlers.datetime
#
DateTimeHandler
#
Bases: TypeHandler
TypeHandler for Python datetime objects.
Serializes datetime to Unix timestamp format compatible with iOS PTime.
Source code in capturegraph-lib/capturegraph/data/typed_json/handlers/datetime.py
decodable_schema()
#
Return schema: expects 'time_since_1970' key with numeric value.
decode(obj)
#
Decode JSON dict to datetime.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Dict[str, Any]
|
Dict with 'time_since_1970' key containing seconds since epoch. |
required |
Returns:
| Type | Description |
|---|---|
Any | None
|
datetime instance, or None if schema doesn't match. |
Source code in capturegraph-lib/capturegraph/data/typed_json/handlers/datetime.py
encodable_types()
#
encode(obj)
#
Encode datetime to JSON dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
datetime instance to encode. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any] | None
|
Dict with 'time_since_1970' key, or None if not a datetime. |