from datetime import date
from typing import Optional
from tdw_catalog.utils import MetadataFieldType
import tdw_catalog.metadata.field as field
[docs]class Field(field.MetadataField[date]):
"""
Add dates to the :class:`.Dataset` to keep track of timelines or events
Attributes
----------
None
"""
def __init__(self, key: str, value: Optional[date]) -> None:
super().__init__(key, value)
def serialize(self) -> dict:
res = super().serialize()
res["value"] = self.value.strftime("%Y-%m-%d") if self.value is not None else None
res["field_type"] = MetadataFieldType.FT_DATE
return res