fix: ensure string timestamps are converted to UTC in MessageTable model (#5881)
This commit is contained in:
parent
eedabbe50f
commit
f5929fe58e
1 changed files with 4 additions and 0 deletions
|
|
@ -137,6 +137,10 @@ class MessageTable(MessageBase, table=True): # type: ignore[call-arg]
|
||||||
if value.tzinfo is None:
|
if value.tzinfo is None:
|
||||||
value = value.replace(tzinfo=timezone.utc)
|
value = value.replace(tzinfo=timezone.utc)
|
||||||
return value.strftime("%Y-%m-%d %H:%M:%S %Z")
|
return value.strftime("%Y-%m-%d %H:%M:%S %Z")
|
||||||
|
if isinstance(value, str):
|
||||||
|
# Make sure the timestamp is in UTC
|
||||||
|
value = datetime.fromisoformat(value).replace(tzinfo=timezone.utc)
|
||||||
|
return value.strftime("%Y-%m-%d %H:%M:%S %Z")
|
||||||
return value
|
return value
|
||||||
|
|
||||||
@field_validator("flow_id", mode="before")
|
@field_validator("flow_id", mode="before")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue