Skip to content

Commit

Permalink
use tzlocal to get the local time
Browse files Browse the repository at this point in the history
  • Loading branch information
cin-cris committed Nov 6, 2024
1 parent 908452c commit 090e91e
Show file tree
Hide file tree
Showing 19 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ repos:
"types-requests",
"sqlmodel",
"types-Markdown",
types-tzlocal,
]
args: ["--check-untyped-defs", "--ignore-missing-imports"]
exclude: "^templates/"
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9 changes: 4 additions & 5 deletions libs/ktem/ktem/db/base_models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import datetime
import uuid
from typing import Optional
from zoneinfo import ZoneInfo

from sqlalchemy import JSON, Column
from sqlmodel import Field, SQLModel
from theflow.settings import settings as flowsettings
from tzlocal import get_localzone


class BaseConversation(SQLModel):
Expand All @@ -26,9 +25,9 @@ class BaseConversation(SQLModel):
default_factory=lambda: uuid.uuid4().hex, primary_key=True, index=True
)
name: str = Field(
default_factory=lambda: datetime.datetime.now(
ZoneInfo(getattr(flowsettings, "TIME_ZONE", "UTC"))
).strftime("%Y-%m-%d %H:%M:%S")
default_factory=lambda: datetime.datetime.now(get_localzone()).strftime(
"%Y-%m-%d %H:%M:%S"
)
)
user: int = Field(default=0) # For now we only have one user

Expand Down
1 change: 1 addition & 0 deletions libs/ktem/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies = [
"gradio>=4.31.0,<5",
"python-multipart==0.0.12", # required for gradio, pinning to avoid yanking issues with micropip (fixed in gradio >= 5.4.0)
"markdown>=3.6,<4",
"tzlocal>=5.0",
]
authors = [
{ name = "@trducng", email = "john@cinnamon.is" },
Expand Down
1 change: 1 addition & 0 deletions libs/ktem/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
platformdirs
tzlocal

0 comments on commit 090e91e

Please sign in to comment.