Issue with timezone
Having an issue with timezone ‘America/Bogota’ should be the same as ‘America/NewYork’ but if you pull time based on it from pytz which uses your database. You get the wrong timezone a 3 or 4 hour ahead timezone. Feel free to ask for more testing info if needed .. Thanks
Ty Hanks wrote:
Having an issue with timezone ‘America/Bogota’ should be the same as ‘America/NewYork’ but if you pull time based on it from pytz which uses your database. You get the wrong timezone a 3 or 4 hour ahead timezone. Feel free to ask for more testing info if needed .. Thanks
You will probably get more questions, but let’s start here: First, these two time zones are currently (2023-07-17) NOT the same. The United States observes summer time (DST), while Colombia does not. So America/New_York is currently UTC–4, while America/Bogota is currently UTC–5. Which zone (or both) are you “pulling time” from, what value(s) are you expecting, and what value(s) are you seeing instead? -- Doug Ewell, CC, ALB | Lakewood, CO, US | ewellic.org
On 2023-07-15 15:51, Ty Hanks via tz wrote:
Having an issue with timezone ‘America/Bogota’ should be the same as ‘America/NewYork’
No, they're different timezones as Doug mentioned. Also, it's "America/New_York" not "America/NewYork".
if you pull time based on it from pytz which uses your database. You get the wrong timezone a 3 or 4 hour ahead timezone.
Actually, I don't get that. It works for me on Fedora 38; see below. If you're having trouble, please try the recipe below to help you get started debugging. Also, please read Paul Ganssle's "pytz: The Fastest Footgun in the West" <https://blog.ganssle.io/articles/2018/03/pytz-fastest-footgun.html>. $ python3 Python 3.11.4 (main, Jun 7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)] on linux Type "help", "copyright", "credits" or "license" for more information.
from datetime import datetime from pytz import timezone format = "%Y-%m-%d %H:%M:%S %z (%Z)" now = datetime.now(timezone('UTC')) print(now.strftime(format)) 2023-07-17 19:12:05 +0000 (UTC) print(now.astimezone(timezone('America/New_York')).strftime(format)) 2023-07-17 15:12:05 -0400 (EDT) print(now.astimezone(timezone('America/Bogota')).strftime(format)) 2023-07-17 14:12:05 -0500 (-05)
On 2023-07-17 13:19, Paul Eggert via tz wrote:
On 2023-07-15 15:51, Ty Hanks via tz wrote:
Having an issue with timezone ‘America/Bogota’ should be the same as ‘America/NewYork’
No, they're different timezones as Doug mentioned. Also, it's "America/New_York" not "America/NewYork".
if you pull time based on it from pytz which uses your database. You get the wrong timezone a 3 or 4 hour ahead timezone.
Actually, I don't get that. It works for me on Fedora 38; see below. If you're having trouble, please try the recipe below to help you get started debugging.
Also, please read Paul Ganssle's "pytz: The Fastest Footgun in the West" <https://blog.ganssle.io/articles/2018/03/pytz-fastest-footgun.html>.
$ python3 Python 3.11.4 (main, Jun 7 2023, 00:00:00) [GCC 13.1.1 20230511 (Red Hat 13.1.1-2)] on linux Type "help", "copyright", "credits" or "license" for more information.
from datetime import datetime from pytz import timezone format = "%Y-%m-%d %H:%M:%S %z (%Z)" now = datetime.now(timezone('UTC')) print(now.strftime(format)) 2023-07-17 19:12:05 +0000 (UTC) print(now.astimezone(timezone('America/New_York')).strftime(format)) 2023-07-17 15:12:05 -0400 (EDT) print(now.astimezone(timezone('America/Bogota')).strftime(format)) 2023-07-17 14:12:05 -0500 (-05)
Also, do you have the latest pytz 2023.3 installed? IANAP but have noticed while testing pytz issues, that if anything is not quite right, you get UTC/GMT rather than whatever you think you asked for! Current built-in python 3+ datetime uses the python zoneinfo module to access your local system zoneinfo (tzdata) package, if it is set up in a standard way, and your python is set up to use it that way. If there is some discrepancy, e.g. Windows, you can install python tzdata package version 2023.3 which will be used by the python zoneinfo module: https://docs.python.org/3/library/zoneinfo.html The python-dateutil package current version 2.8.2 handles relative delta dates and supports date parsing. -- Take care. Thanks, Brian Inglis Calgary, Alberta, Canada La perfection est atteinte Perfection is achieved non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut -- Antoine de Saint-Exupéry
participants (4)
-
Brian Inglis -
Doug Ewell -
Paul Eggert -
Ty Hanks