Skip to content

Commit

Permalink
feat: change date to utc datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Trotsenko committed Aug 17, 2023
1 parent 743543d commit 047c452
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/db/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class User(BaseModel):
username = CharField(null=True)
first_name = CharField()
last_name = CharField(null=True)
reg_date = DateField()
reg_date = DateTimeField()

class Meta:
table_name = 'User'

class Chat(BaseModel):
id = BigAutoField(unique=True)
reg_date = DateField()
reg_date = DateTimeField()

class Meta:
table_name = 'Chat'
Expand All @@ -42,7 +42,7 @@ class Interaction(BaseModel):
from_user = ForeignKeyField(User, backref='interactions')
to_user = ForeignKeyField(User, backref='interact_to')
chat_id = ForeignKeyField(Chat)
date = DateField()
date = DateTimeField()

class Meta:
table_name = 'Interaction'
Expand Down
6 changes: 3 additions & 3 deletions src/db/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from src.db.database import Chat, User, Interaction, UserChat, db

def create_chat(chat_id: int) -> None:
Chat.create(id=chat_id, reg_date=datetime.datetime.now())
Chat.create(id=chat_id, reg_date=datetime.datetime.utcnow())

def create_user(id: int, username: str, first_name: str, last_name: str) -> None:
User.create(id=id, username=username, first_name=first_name, last_name=last_name, reg_date=datetime.datetime.now())
User.create(id=id, username=username, first_name=first_name, last_name=last_name, reg_date=datetime.datetime.utcnow())

def create_user_chat(user_id: int, chat_id: int) -> None:
user = User.get(User.id == user_id)
Expand All @@ -17,7 +17,7 @@ def create_user_chat(user_id: int, chat_id: int) -> None:
def create_interaction(from_user_id: int, to_user_id: int, chat_id: int) -> None:
from_user = User.get(User.id == from_user_id)
to_user = User.get(User.id == to_user_id)
Interaction.create(from_user=from_user, to_user=to_user, chat_id=chat_id, date=datetime.datetime.now())
Interaction.create(from_user=from_user, to_user=to_user, chat_id=chat_id, date=datetime.datetime.utcnow())



Expand Down

0 comments on commit 047c452

Please sign in to comment.