Skip to content

Commit

Permalink
Merge pull request #2 from progmatic-99/dev
Browse files Browse the repository at this point in the history
feat: convert timezone to ist
  • Loading branch information
progmatic-99 committed Apr 23, 2024
2 parents f811f7e + f72816b commit 2adf2dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import sqlite3
import re
from pytz import timezone
from datetime import datetime
import prettytable as pt
from telegram import Update
Expand Down Expand Up @@ -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])

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2adf2dc

Please sign in to comment.