Skip to content

Commit

Permalink
Coerce created to datetime for document string representation
Browse files Browse the repository at this point in the history
  • Loading branch information
shamoon committed Jan 15, 2023
1 parent c968380 commit 6290ad1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/documents/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ class Meta:

def __str__(self) -> str:

# Convert str to datetime before localize
if self.created is not None and isinstance(self.created, str):
try:
self.created = dateutil.parser.isoparse(self.created)
except Exception:
pass

# Convert UTC database time to local time
created = datetime.date.isoformat(timezone.localdate(self.created))

Expand Down

0 comments on commit 6290ad1

Please sign in to comment.