Questions tagged [zoneinfo]
54 questions
2
votes
0 answers
Why do pandas and python differ in how they convert a datetime to America/Boise?
Here's an example:
import pandas as pd
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
string = '2038-04-01 09:00:00.000000'
dt = datetime.fromisoformat(string)
dt = dt.replace(tzinfo=timezone.utc)
tz =…

ignoring_gravity
- 6,677
- 4
- 32
- 65
2
votes
2 answers
Why does ZoneInfo("UTC") do different time conversions from timezone.utc?
I was trying to convert a datetime from one timezone to another. I'm in the process of updating our Python codebase to stop relying on utilities we don't need anymore. In particular, I'm deprecating our use of arrow and pytz. In doing so, I noticed…

jaywhy13
- 1,068
- 12
- 16
2
votes
2 answers
How to get timezone rules version used by datetime?
In John Skeet's blog post about handling timezone information when storing future datetimes, he suggests storing the version of timezone rules in the database along with the local time and timezone id.
His example:
ID: 1
Name: KindConf
LocalStart:…

roob
- 2,419
- 3
- 29
- 45
2
votes
1 answer
How can we find possible time zone names corresponding to a time zone abbreviation?
Given a time zone abbreviation, is there a way to get a list of possible time zones?
Like IST could mean one of the following:
Asia/Kolkata (India)
Asia/Tel_Aviv (Israel)
Europe/Dublin (Ireland)
What I was looking for was a way to get…

J...S
- 5,079
- 1
- 20
- 35
2
votes
3 answers
Is there anyway i can convert a "Australia/Melbourne" time zone into some .net base class library object?
I have some data from a 3rd party that includes some string Language property data. Some sample data retrieved looks like :
"Australia/Melbourne"
When i investigated that what the property data-type was based on, it's a Zone Info (tz database /…

Pure.Krome
- 84,693
- 113
- 396
- 647
2
votes
1 answer
mysql_tzinfo_to_sql - updating the timezone tables after you already loaded them and other questions
I just used mysql_tzinfo_to_sql to load the zoneinfo database into mysql. They all imported fine.
[root@db ~]# mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql mysql
I have some questions that I can't seem to find answers for :
Are the names in…

user756659
- 3,372
- 13
- 55
- 110
2
votes
1 answer
Timezone is wrong in database
I have made a date with the CURRENT_TIMESTAMP function in phpmyadmin. And the output value of the hours is wrong by 1hour. I have tried changing it in mysql using the
SET TIME_ZONE = '+01:00';
However it will still submit the date with 1 hour…

Philip Svenningsen Arnevig
- 59
- 1
- 8
1
vote
2 answers
How to change local time without using date
It's a remote server so no GUI or fancy stuff installed, I connect to that host using SSH.
For security reasons I suppose, I cannot use the 'date -s' command to change the local server's current time.
$ cat /etc/issues ==> Ubuntu 10.04 LTS
$ uname…

Taher
- 11,902
- 2
- 28
- 44
1
vote
1 answer
Python pytz, zoneinfo and daylight savings time
I am currently attempting to migrate a code base from using pytz to using Python's zoneinfo library. I've run into an issue with how zoneinfo handles daylight saving time transitions when compared to how pytz handles them.
Suppose I have a naive…

Paul
- 13
- 3
1
vote
0 answers
pytz and ZoneInfo return different times for same functions. What's wrong with my implementation?
I am trying to add a timezone to a time without timezone. However, using 2 libraries gives 2 different results:
from datetime import datetime
import pytz
from zoneinfo import ZoneInfo
cur = datetime.now(tz=None)
print("utc,", cur) # -> 2023-02-24…

Aizaz
- 39
- 7
1
vote
1 answer
Localize time zone based on column in pandas
I am trying to set timezone to a datetime column, based on another column containing the time zone.
Example data:
DATETIME VALUE TIME_ZONE
0 2021-05-01 00:00:00 1.00 Europe/Athens
1 2021-05-01 00:00:00 2.13 …

oskros
- 3,101
- 2
- 9
- 28
1
vote
3 answers
American time zones like CT, give error: ZoneInfoNotFoundError: 'No time zone found with key CT'
Python 3.9 introduced the zoneinfo module:
The zoneinfo module provides a concrete time zone implementation to support the IANA time zone database as originally specified in PEP 615. By default, zoneinfo uses the system’s time zone data if…

Flimm
- 136,138
- 45
- 251
- 267
1
vote
2 answers
Using zoneinfo with pandas.date_range
I am trying to use zoneinfo instead of pytz. I am running into a problem using zoneinfo to initiate dates and passing it on to pd.date_range.
Below is an example of doing the exact same thing with pytz and with zoneinfo. But, while passing it to…

Aviv Fried
- 65
- 4
1
vote
1 answer
How does ZoneInfo handle DST in the distant future?
I'm trying to understand how the zoneinfo module figures out daylight savings time transitions in the distant future while it seems that dateutil and pytz both give up on daylight savings time transitions.
I know these transitions aren't really…

Michael S.
- 327
- 1
- 2
- 11
1
vote
1 answer
DRF TimeZoneField: not JSON serializable error
I have django model:
from django.db import models
from timezone_field import TimeZoneField
class Client(models.Model):
time_zone = TimeZoneField(choices_display='WITH_GMT_OFFSET')
And APIView for this model:
class ClientAPIView(APIView):
…

Sergey
- 83
- 7