Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9f8c32e

Browse files
hodgestarjkseppan
authored andcommitted
Update pytz to version 2011c.
1 parent fb9029e commit 9f8c32e

22 files changed

Lines changed: 408 additions & 243 deletions

File tree

lib/pytz/CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@
4848

4949
- Fix test_zdump tests and bugs the fixed tests picked up, including
5050
the fix for Bug #427444.
51+
52+
2011-02-08
53+
54+
- Python 3.1 support.

lib/pytz/README.txt

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Introduction
77
~~~~~~~~~~~~
88

99
pytz brings the Olson tz database into Python. This library allows
10-
accurate and cross platform timezone calculations using Python 2.3
10+
accurate and cross platform timezone calculations using Python 2.4
1111
or higher. It also solves the issue of ambiguous times at the end
1212
of daylight savings, which you can read more about in the Python
1313
Library Reference (``datetime.tzinfo``).
@@ -72,7 +72,7 @@ This is used to localize a naive datetime (datetime with no timezone
7272
information):
7373

7474
>>> loc_dt = eastern.localize(datetime(2002, 10, 27, 6, 0, 0))
75-
>>> print loc_dt.strftime(fmt)
75+
>>> print(loc_dt.strftime(fmt))
7676
2002-10-27 06:00:00 EST-0500
7777

7878
The second way of building a localized time is by converting an existing
@@ -209,7 +209,7 @@ datetime.timedelta(0)
209209
'NST'
210210

211211
If ``is_dst`` is not specified, ambiguous timestamps will raise
212-
an ``AmbiguousTimeError`` exception.
212+
an ``pytz.exceptions.AmbiguousTimeError`` exception.
213213

214214
>>> tz.utcoffset(normal)
215215
datetime.timedelta(-1, 77400)
@@ -218,18 +218,22 @@ datetime.timedelta(0, 3600)
218218
>>> tz.tzname(normal)
219219
'NDT'
220220

221-
>>> tz.utcoffset(ambiguous)
222-
Traceback (most recent call last):
223-
[...]
224-
AmbiguousTimeError: 2009-10-31 23:30:00
225-
>>> tz.dst(ambiguous)
226-
Traceback (most recent call last):
227-
[...]
228-
AmbiguousTimeError: 2009-10-31 23:30:00
229-
>>> tz.tzname(ambiguous)
230-
Traceback (most recent call last):
231-
[...]
232-
AmbiguousTimeError: 2009-10-31 23:30:00
221+
>>> import pytz.exceptions
222+
>>> try:
223+
... tz.utcoffset(ambiguous)
224+
... except pytz.exceptions.AmbiguousTimeError:
225+
... print('pytz.exceptions.AmbiguousTimeError: %s' % ambiguous)
226+
pytz.exceptions.AmbiguousTimeError: 2009-10-31 23:30:00
227+
>>> try:
228+
... tz.dst(ambiguous)
229+
... except pytz.exceptions.AmbiguousTimeError:
230+
... print('pytz.exceptions.AmbiguousTimeError: %s' % ambiguous)
231+
pytz.exceptions.AmbiguousTimeError: 2009-10-31 23:30:00
232+
>>> try:
233+
... tz.tzname(ambiguous)
234+
... except pytz.exceptions.AmbiguousTimeError:
235+
... print('pytz.exceptions.AmbiguousTimeError: %s' % ambiguous)
236+
pytz.exceptions.AmbiguousTimeError: 2009-10-31 23:30:00
233237

234238

235239
Problems with Localtime
@@ -261,18 +265,19 @@ in different timezones or analyze log files it is not acceptable.
261265
The best and simplest solution is to stick with using UTC. The pytz
262266
package encourages using UTC for internal timezone representation by
263267
including a special UTC implementation based on the standard Python
264-
reference implementation in the Python documentation. This timezone
265-
unpickles to be the same instance, and pickles to a relatively small
266-
size. The UTC implementation can be obtained as pytz.utc, pytz.UTC,
267-
or pytz.timezone('UTC').
268+
reference implementation in the Python documentation.
269+
270+
The UTC timezone unpickles to be the same instance, and pickles to a
271+
smaller size than other pytz tzinfo instances. The UTC implementation
272+
can be obtained as pytz.utc, pytz.UTC, or pytz.timezone('UTC').
268273

269274
>>> import pickle, pytz
270275
>>> dt = datetime(2005, 3, 1, 14, 13, 21, tzinfo=utc)
271276
>>> naive = dt.replace(tzinfo=None)
272277
>>> p = pickle.dumps(dt, 1)
273278
>>> naive_p = pickle.dumps(naive, 1)
274-
>>> len(p), len(naive_p), len(p) - len(naive_p)
275-
(60, 43, 17)
279+
>>> len(p) - len(naive_p)
280+
17
276281
>>> new = pickle.loads(p)
277282
>>> new == dt
278283
True
@@ -295,7 +300,7 @@ facility for constructing them unambiguously:
295300
>>> loc_dt = datetime(2002, 10, 27, 1, 30, 00)
296301
>>> est_dt = eastern.localize(loc_dt, is_dst=True)
297302
>>> edt_dt = eastern.localize(loc_dt, is_dst=False)
298-
>>> print est_dt.strftime(fmt), '/', edt_dt.strftime(fmt)
303+
>>> print(est_dt.strftime(fmt) + ' / ' + edt_dt.strftime(fmt))
299304
2002-10-27 01:30:00 EDT-0400 / 2002-10-27 01:30:00 EST-0500
300305

301306
If you pass None as the is_dst flag to localize(), pytz will refuse to
@@ -306,19 +311,23 @@ For example, 1:30am on 27th Oct 2002 happened twice in the US/Eastern
306311
timezone when the clocks where put back at the end of Daylight Savings
307312
Time:
308313

309-
>>> eastern.localize(datetime(2002, 10, 27, 1, 30, 00), is_dst=None)
310-
Traceback (most recent call last):
311-
...
312-
AmbiguousTimeError: 2002-10-27 01:30:00
314+
>>> dt = datetime(2002, 10, 27, 1, 30, 00)
315+
>>> try:
316+
... eastern.localize(dt, is_dst=None)
317+
... except pytz.exceptions.AmbiguousTimeError:
318+
... print('pytz.exceptions.AmbiguousTimeError: %s' % dt)
319+
pytz.exceptions.AmbiguousTimeError: 2002-10-27 01:30:00
313320

314321
Similarly, 2:30am on 7th April 2002 never happened at all in the
315322
US/Eastern timezone, as the clocks where put forward at 2:00am skipping
316323
the entire hour:
317324

318-
>>> eastern.localize(datetime(2002, 4, 7, 2, 30, 00), is_dst=None)
319-
Traceback (most recent call last):
320-
...
321-
NonExistentTimeError: 2002-04-07 02:30:00
325+
>>> dt = datetime(2002, 4, 7, 2, 30, 00)
326+
>>> try:
327+
... eastern.localize(dt, is_dst=None)
328+
... except pytz.exceptions.NonExistentTimeError:
329+
... print('pytz.exceptions.NonExistentTimeError: %s' % dt)
330+
pytz.exceptions.NonExistentTimeError: 2002-04-07 02:30:00
322331

323332
Both of these exceptions share a common base class to make error handling
324333
easier:
@@ -393,14 +402,14 @@ for a particular country, looked up using the ISO 3166 country code.
393402
It returns a list of strings that can be used to retrieve the relevant
394403
tzinfo instance using ``pytz.timezone()``:
395404

396-
>>> pytz.country_timezones['nz']
397-
['Pacific/Auckland', 'Pacific/Chatham']
405+
>>> print(' '.join(pytz.country_timezones['nz']))
406+
Pacific/Auckland Pacific/Chatham
398407

399408
The Olson database comes with a ISO 3166 country code to English country
400409
name mapping that pytz exposes as a dictionary:
401410

402-
>>> pytz.country_names['nz']
403-
'New Zealand'
411+
>>> print(pytz.country_names['nz'])
412+
New Zealand
404413

405414

406415
What is UTC
@@ -478,10 +487,10 @@ using the ``country_timezones()`` function. It requires an ISO-3166
478487
two letter country code.
479488

480489
>>> from pytz import country_timezones
481-
>>> country_timezones('ch')
482-
['Europe/Zurich']
483-
>>> country_timezones('CH')
484-
['Europe/Zurich']
490+
>>> print(' '.join(country_timezones('ch')))
491+
Europe/Zurich
492+
>>> print(' '.join(country_timezones('CH')))
493+
Europe/Zurich
485494

486495

487496
License
@@ -541,3 +550,4 @@ Contact
541550

542551
Stuart Bishop <[email protected]>
543552

553+

0 commit comments

Comments
 (0)