Skip to content

Commit

Permalink
Ensure generated datetimes are in UTC, closes #840
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmezzetti committed Dec 21, 2024
1 parent 952a757 commit 5227604
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/python/txtai/database/rdbms.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def insert(self, documents, index=0):
self.initialize()

# Get entry date
entry = datetime.datetime.now()
entry = datetime.datetime.now(datetime.timezone.utc)

# Insert documents
for uid, document, tags in documents:
Expand Down
6 changes: 3 additions & 3 deletions src/python/txtai/database/schema/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Document(Base):
id = Column(idcolumn(), primary_key=True)
data = Column(JSON)
tags = Column(Text)
entry = Column(DateTime)
entry = Column(DateTime(timezone=True))

class Object(Base):
"""
Expand All @@ -76,7 +76,7 @@ class Object(Base):
id = Column(idcolumn(), primary_key=True)
object = Column(LargeBinary)
tags = Column(Text)
entry = Column(DateTime)
entry = Column(DateTime(timezone=True))

class SectionBase(Base):
"""
Expand All @@ -89,7 +89,7 @@ class SectionBase(Base):
id = Column(idcolumn(), index=True)
text = Column(Text)
tags = Column(Text)
entry = Column(DateTime)
entry = Column(DateTime(timezone=True))

class Section(SectionBase):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/python/txtai/workflow/task/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __call__(self, elements, executor=None):

# Add timestamp to filename
if self.timestamp:
timestamp = datetime.datetime.now().strftime("%Y%m%dT%H%M%S")
timestamp = datetime.datetime.now(datetime.timezone.utc).strftime("%Y%m%dT%H%M%SZ")
parts[-1] = timestamp + parts[-1]

# Create full path to output file
Expand Down

0 comments on commit 5227604

Please sign in to comment.