manhteky123 commited on
Commit
1363e09
·
1 Parent(s): 969821d

Add Vietnam timezone (UTC+7) for timestamp

Browse files
Files changed (2) hide show
  1. app/database.py +4 -1
  2. requirements.txt +1 -0
app/database.py CHANGED
@@ -1,6 +1,7 @@
1
  import sqlite3
2
  from datetime import datetime
3
  from flask import current_app, g
 
4
 
5
  def get_db():
6
  """Kết nối database SQLite"""
@@ -34,7 +35,9 @@ def init_db():
34
  def save_sentiment(text, sentiment):
35
  """Lưu kết quả phân loại vào database"""
36
  db = get_db()
37
- timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
 
 
38
  db.execute(
39
  'INSERT INTO sentiments (text, sentiment, timestamp) VALUES (?, ?, ?)',
40
  (text, sentiment, timestamp)
 
1
  import sqlite3
2
  from datetime import datetime
3
  from flask import current_app, g
4
+ import pytz
5
 
6
  def get_db():
7
  """Kết nối database SQLite"""
 
35
  def save_sentiment(text, sentiment):
36
  """Lưu kết quả phân loại vào database"""
37
  db = get_db()
38
+ # Lấy thời gian theo múi giờ Việt Nam (UTC+7)
39
+ vietnam_tz = pytz.timezone('Asia/Ho_Chi_Minh')
40
+ timestamp = datetime.now(vietnam_tz).strftime('%Y-%m-%d %H:%M:%S')
41
  db.execute(
42
  'INSERT INTO sentiments (text, sentiment, timestamp) VALUES (?, ?, ?)',
43
  (text, sentiment, timestamp)
requirements.txt CHANGED
@@ -6,3 +6,4 @@ underthesea==6.7.0
6
  sentencepiece==0.1.99
7
  protobuf==3.20.3
8
  numpy<2.0.0
 
 
6
  sentencepiece==0.1.99
7
  protobuf==3.20.3
8
  numpy<2.0.0
9
+ pytz==2024.1