From 522760447d8094a7ba08feee8e5f47decc991fd5 Mon Sep 17 00:00:00 2001 From: davidmezzetti <561939+davidmezzetti@users.noreply.github.com> Date: Sat, 21 Dec 2024 07:16:27 -0500 Subject: [PATCH] Ensure generated datetimes are in UTC, closes #840 --- src/python/txtai/database/rdbms.py | 2 +- src/python/txtai/database/schema/orm.py | 6 +++--- src/python/txtai/workflow/task/export.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/python/txtai/database/rdbms.py b/src/python/txtai/database/rdbms.py index 1c96eb9fa..6a718f2c0 100644 --- a/src/python/txtai/database/rdbms.py +++ b/src/python/txtai/database/rdbms.py @@ -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: diff --git a/src/python/txtai/database/schema/orm.py b/src/python/txtai/database/schema/orm.py index 03edb6b4a..0815abf88 100644 --- a/src/python/txtai/database/schema/orm.py +++ b/src/python/txtai/database/schema/orm.py @@ -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): """ @@ -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): """ @@ -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): """ diff --git a/src/python/txtai/workflow/task/export.py b/src/python/txtai/workflow/task/export.py index 70b8dcc7f..f0c56016d 100644 --- a/src/python/txtai/workflow/task/export.py +++ b/src/python/txtai/workflow/task/export.py @@ -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