Fix: Fingerprint was ignoring the time aspect which is obviously very important

This commit is contained in:
Amritanshu Agrawal 2023-08-07 12:47:57 +05:30
parent bc61eeacd3
commit 48ec2df10d

View File

@ -20,11 +20,11 @@ class Fingerprint(BaseModel):
@field_validator("date_", mode="before") @field_validator("date_", mode="before")
@classmethod @classmethod
def parse_date(cls, value: date | str) -> date: def parse_date(cls, value: datetime | str) -> datetime:
if isinstance(value, date): if isinstance(value, datetime):
return value return value
return datetime.strptime(value, "%d-%b-%Y").date() return datetime.strptime(value, "%d-%b-%Y %H:%M")
@field_serializer("date_") @field_serializer("date_")
def serialize_date(self, value: date, info: FieldSerializationInfo) -> str: def serialize_date(self, value: date, info: FieldSerializationInfo) -> str:
return value.strftime("%d-%b-%Y") return value.strftime("%d-%b-%Y %H:%M")