Questions tagged [pytz]

pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.3 or higher. It also solves the issue of ambiguous times at the end of daylight savings.

pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.3 or higher. It also solves the issue of ambiguous times at the end of daylight savings.

717 questions
16
votes
3 answers

Django IPython sqlite complains about naive datetime

I have a new project in Django 1.4, using sqlite db. Also using django_extenstions' shell_plus with no problems. When I installed IPython, both shell and shell_plus started to complain…
frnhr
  • 12,354
  • 9
  • 63
  • 90
15
votes
2 answers

UnknownTimezoneError Exception Raised with Python Application Compiled with Py2Exe

I'm having a problem distributing an application that utilizes pytz. I'm using Py2Exe to create an executable from my Python source. For a simple example of the problem I'm having, I have: pytz_test.py: import pytz tz_au =…
Lance
  • 399
  • 1
  • 5
  • 14
15
votes
4 answers

PytzUsageWarning: The zone attribute is specific to pytz's interface; please migrate to a new time zone provider

I am writing a simple function that sends messages based on a schedule using AsyncIOScheduler. scheduler = AsyncIOScheduler() scheduler.add_job(job, "cron", day_of_week="mon-fri", hour = "16") scheduler.start() It seems to work, but I always get…
Sergo055
  • 146
  • 1
  • 1
  • 8
15
votes
1 answer

How do I combine a timezone aware date and time in Python?

I have a date and a time that I'm attempting to combine in Python. The time is timezone aware. However, when I try and combine them, I get the wrong time. import pytz from datetime import time, date NYC_TIME =…
Chris B.
  • 85,731
  • 25
  • 98
  • 139
14
votes
1 answer

get the DST boundaries of a given timezone in python

Is it possible to get the DST boundaries of a given timezone with pytz?
nnachefski
  • 1,552
  • 2
  • 18
  • 29
14
votes
9 answers

Timezone Information Missing in pytz?

I'm having a very weird problem with Python's pytz: it seems to have an incomplete catalog of timezones on my system (MacOS X 10.8.5, system Python 2.7.5). >>> from pytz import timezone >>> import pytz >>> utc = pytz.utc >>> utc.zone 'UTC' >>>…
Konstantin Greger
  • 143
  • 1
  • 1
  • 5
14
votes
2 answers

How can I convert windows timezones to timezones pytz understands?

In a windows python environment I can get the local timezone like this, but it's not usable with pytz: >>> import win32timezone >>> win32timezone.TimeZoneInfo.local() TimeZoneInfo(u'US Mountain Standard Time', True) >>>…
Chris Matta
  • 3,263
  • 3
  • 35
  • 48
14
votes
3 answers

How to handle DST and TZ in recurring events?

Does dateutil rrule support DST and TZ? Need something similar to iCalendar RRULE. If not - how to tackle this problem (scheduling recurring events & DST offset change) Imports >>> from django.utils import timezone >>> import pytz >>> from datetime…
g00fy
  • 4,717
  • 1
  • 30
  • 46
13
votes
5 answers

Python: All possible Timezone Abbreviations for given Timezone Name (and vise versa)

Using pytz, I know how to get a listing a Timezone names, but I would like to get all possible Timezone abbreviations for each Timezone name: import pytz list(pytz.common_timezones) ['Africa/Abidjan', 'Africa/Accra', 'Africa/Addis_Ababa',...] What…
jeff00seattle
  • 1,291
  • 5
  • 17
  • 31
13
votes
2 answers

Python datetime not including DST when using pytz timezone

If I convert a UTC datetime to swedish format, summertime is included (CEST). However, while creating a datetime with sweden as the timezone, it gets CET instead of CEST. Why is this? >>> # Modified for readability >>> import pytz >>> import…
Jesper
  • 670
  • 9
  • 16
13
votes
1 answer

Why doesn't pytz localize() produce a datetime object with tzinfo matching the tz object that localized it?

Is there anyone who can help me understand what's going on here? import pytz from datetime import datetime tz = pytz.timezone('Europe/Berlin') print repr(tz) # dt = datetime(2011, 1, 3, 18, 40) result =…
bjmc
  • 2,970
  • 2
  • 32
  • 46
13
votes
2 answers

Weird .astimezone behavior

I am doing some timezone conversions, and I get really weird results. Basically converting between timezones that differ only by whole hours, I still get non-whole results. For example: from datetime import datetime from pytz import…
ibz
  • 44,461
  • 24
  • 70
  • 86
12
votes
3 answers

pytz and Etc/GMT-5

I'm having trouble understanding the conversion between the "Etc/GMT-5" timezone and UTC in pytz. >>> dt = datetime(2009, 9, 9, 10, 0) # September 9 2009, 10:00 >>> gmt_5 = pytz.timezone("Etc/GMT-5") >>> gmt_5.localize(dt) datetime.datetime(2009, 9,…
Deniz Dogan
  • 25,711
  • 35
  • 110
  • 162
12
votes
1 answer

Using freezegun, why do pytz.utc and utcnow() output different datetimes?

I'm puzzled why a function that freezes time with freezegun outputs different UTC times depending on whether datetime.datetime.utcnow() is called, or datetime.datetime.now(pytz.utc). I'm not saying it's broken, just that I don't understand why, and…
Phil Gyford
  • 13,432
  • 14
  • 81
  • 143
12
votes
4 answers

Django Tutorial - ImproperlyConfigured exception (pytz isn't installed)

I'm currently working through the official Django tutorial using version 1.6.1 and version 2.7.5 of python on OSX. I'm working on part 2, which is the admin interface. When I attempt to go to /admin/polls/poll/, I get the following error…
John D.
  • 2,521
  • 3
  • 24
  • 45