diff --git a/handlers.py b/handlers.py index 3fd0eb4..c8407c7 100644 --- a/handlers.py +++ b/handlers.py @@ -2,6 +2,7 @@ import sqlite3 import re +from pytz import timezone from datetime import datetime import prettytable as pt from telegram import Update @@ -161,7 +162,11 @@ async def recents(update: Update, ctx: ContextTypes.DEFAULT_TYPE): for name, quantity, price, time in items: # sqlite3 returns a str for datetime time = datetime.strptime(time, "%Y-%m-%d %H:%M:%S") - formatted_time = time.strftime("%d/%m %H:%M") + formatted_time = ( + time.replace(tzinfo=timezone("UTC")) + .astimezone(timezone("Asia/Kolkata")) + .strftime("%d/%m %H:%M") + ) table.add_row([name, quantity, price, formatted_time]) diff --git a/requirements.txt b/requirements.txt index 27de4f7..ffdd62f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ idna==3.6 prettytable==3.9.0 python-dotenv==1.0.1 python-telegram-bot==20.7 +pytz==2024.1 sniffio==1.3.0 typing-extensions==4.9.0 wcwidth==0.2.13