Open vahidtwo opened 6 months ago
I don't use pytz, but this could be a pytz issue because if you run the same code using datetime
instead of jdatetime
you'll get the same result.
If you can upgrade your Python, try using the zoneinfo
module from the standard library, it was added in Python 3.9. It works as expected for me. Sample code:
import datetime
import pytz
from datetime import UTC
from zoneinfo import ZoneInfo
def try_tz(tehran_timezone):
tehran_dt = datetime.datetime(2024, 2, 28, 15, 16, 13, tzinfo=tehran_timezone)
print(tehran_dt)
tehran_to_utc = tehran_dt.astimezone(UTC)
print(tehran_to_utc)
back_to_tehran = tehran_to_utc.astimezone(tehran_timezone)
print(back_to_tehran)
try_tz(pytz.timezone("Asia/Tehran"))
print()
try_tz(ZoneInfo("Asia/Tehran"))
Similar pytz issues:
Please include your runtime information
Hi i have AJIB issue i try to use jdatetime to convert tehran jalali time to geogorian time (utc) i wtite this code
as u see the minute convert from 16 to 20 and it is a bug