Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

METADATA 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. Metadata-Version: 2.0
  2. Name: pytz
  3. Version: 2018.4
  4. Summary: World timezone definitions, modern and historical
  5. Home-page: http://pythonhosted.org/pytz
  6. Author: Stuart Bishop
  7. Author-email: stuart@stuartbishop.net
  8. Maintainer: Stuart Bishop
  9. Maintainer-email: stuart@stuartbishop.net
  10. License: MIT
  11. Download-URL: http://pypi.python.org/pypi/pytz
  12. Keywords: timezone,tzinfo,datetime,olson,time
  13. Platform: Independent
  14. Classifier: Development Status :: 6 - Mature
  15. Classifier: Intended Audience :: Developers
  16. Classifier: License :: OSI Approved :: MIT License
  17. Classifier: Natural Language :: English
  18. Classifier: Operating System :: OS Independent
  19. Classifier: Programming Language :: Python
  20. Classifier: Programming Language :: Python :: 2
  21. Classifier: Programming Language :: Python :: 2.4
  22. Classifier: Programming Language :: Python :: 2.5
  23. Classifier: Programming Language :: Python :: 2.6
  24. Classifier: Programming Language :: Python :: 2.7
  25. Classifier: Programming Language :: Python :: 3
  26. Classifier: Programming Language :: Python :: 3.0
  27. Classifier: Programming Language :: Python :: 3.1
  28. Classifier: Programming Language :: Python :: 3.2
  29. Classifier: Programming Language :: Python :: 3.3
  30. Classifier: Programming Language :: Python :: 3.4
  31. Classifier: Programming Language :: Python :: 3.5
  32. Classifier: Programming Language :: Python :: 3.6
  33. Classifier: Topic :: Software Development :: Libraries :: Python Modules
  34. pytz - World Timezone Definitions for Python
  35. ============================================
  36. :Author: Stuart Bishop <stuart@stuartbishop.net>
  37. Introduction
  38. ~~~~~~~~~~~~
  39. pytz brings the Olson tz database into Python. This library allows
  40. accurate and cross platform timezone calculations using Python 2.4
  41. or higher. It also solves the issue of ambiguous times at the end
  42. of daylight saving time, which you can read more about in the Python
  43. Library Reference (``datetime.tzinfo``).
  44. Almost all of the Olson timezones are supported.
  45. .. note::
  46. This library differs from the documented Python API for
  47. tzinfo implementations; if you want to create local wallclock
  48. times you need to use the ``localize()`` method documented in this
  49. document. In addition, if you perform date arithmetic on local
  50. times that cross DST boundaries, the result may be in an incorrect
  51. timezone (ie. subtract 1 minute from 2002-10-27 1:00 EST and you get
  52. 2002-10-27 0:59 EST instead of the correct 2002-10-27 1:59 EDT). A
  53. ``normalize()`` method is provided to correct this. Unfortunately these
  54. issues cannot be resolved without modifying the Python datetime
  55. implementation (see PEP-431).
  56. Installation
  57. ~~~~~~~~~~~~
  58. This package can either be installed from a .egg file using setuptools,
  59. or from the tarball using the standard Python distutils.
  60. If you are installing from a tarball, run the following command as an
  61. administrative user::
  62. python setup.py install
  63. If you are installing using setuptools, you don't even need to download
  64. anything as the latest version will be downloaded for you
  65. from the Python package index::
  66. easy_install --upgrade pytz
  67. If you already have the .egg file, you can use that too::
  68. easy_install pytz-2008g-py2.6.egg
  69. Example & Usage
  70. ~~~~~~~~~~~~~~~
  71. Localized times and date arithmetic
  72. -----------------------------------
  73. >>> from datetime import datetime, timedelta
  74. >>> from pytz import timezone
  75. >>> import pytz
  76. >>> utc = pytz.utc
  77. >>> utc.zone
  78. 'UTC'
  79. >>> eastern = timezone('US/Eastern')
  80. >>> eastern.zone
  81. 'US/Eastern'
  82. >>> amsterdam = timezone('Europe/Amsterdam')
  83. >>> fmt = '%Y-%m-%d %H:%M:%S %Z%z'
  84. This library only supports two ways of building a localized time. The
  85. first is to use the ``localize()`` method provided by the pytz library.
  86. This is used to localize a naive datetime (datetime with no timezone
  87. information):
  88. >>> loc_dt = eastern.localize(datetime(2002, 10, 27, 6, 0, 0))
  89. >>> print(loc_dt.strftime(fmt))
  90. 2002-10-27 06:00:00 EST-0500
  91. The second way of building a localized time is by converting an existing
  92. localized time using the standard ``astimezone()`` method:
  93. >>> ams_dt = loc_dt.astimezone(amsterdam)
  94. >>> ams_dt.strftime(fmt)
  95. '2002-10-27 12:00:00 CET+0100'
  96. Unfortunately using the tzinfo argument of the standard datetime
  97. constructors ''does not work'' with pytz for many timezones.
  98. >>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=amsterdam).strftime(fmt)
  99. '2002-10-27 12:00:00 LMT+0020'
  100. It is safe for timezones without daylight saving transitions though, such
  101. as UTC:
  102. >>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=pytz.utc).strftime(fmt)
  103. '2002-10-27 12:00:00 UTC+0000'
  104. The preferred way of dealing with times is to always work in UTC,
  105. converting to localtime only when generating output to be read
  106. by humans.
  107. >>> utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc)
  108. >>> loc_dt = utc_dt.astimezone(eastern)
  109. >>> loc_dt.strftime(fmt)
  110. '2002-10-27 01:00:00 EST-0500'
  111. This library also allows you to do date arithmetic using local
  112. times, although it is more complicated than working in UTC as you
  113. need to use the ``normalize()`` method to handle daylight saving time
  114. and other timezone transitions. In this example, ``loc_dt`` is set
  115. to the instant when daylight saving time ends in the US/Eastern
  116. timezone.
  117. >>> before = loc_dt - timedelta(minutes=10)
  118. >>> before.strftime(fmt)
  119. '2002-10-27 00:50:00 EST-0500'
  120. >>> eastern.normalize(before).strftime(fmt)
  121. '2002-10-27 01:50:00 EDT-0400'
  122. >>> after = eastern.normalize(before + timedelta(minutes=20))
  123. >>> after.strftime(fmt)
  124. '2002-10-27 01:10:00 EST-0500'
  125. Creating local times is also tricky, and the reason why working with
  126. local times is not recommended. Unfortunately, you cannot just pass
  127. a ``tzinfo`` argument when constructing a datetime (see the next
  128. section for more details)
  129. >>> dt = datetime(2002, 10, 27, 1, 30, 0)
  130. >>> dt1 = eastern.localize(dt, is_dst=True)
  131. >>> dt1.strftime(fmt)
  132. '2002-10-27 01:30:00 EDT-0400'
  133. >>> dt2 = eastern.localize(dt, is_dst=False)
  134. >>> dt2.strftime(fmt)
  135. '2002-10-27 01:30:00 EST-0500'
  136. Converting between timezones is more easily done, using the
  137. standard astimezone method.
  138. >>> utc_dt = utc.localize(datetime.utcfromtimestamp(1143408899))
  139. >>> utc_dt.strftime(fmt)
  140. '2006-03-26 21:34:59 UTC+0000'
  141. >>> au_tz = timezone('Australia/Sydney')
  142. >>> au_dt = utc_dt.astimezone(au_tz)
  143. >>> au_dt.strftime(fmt)
  144. '2006-03-27 08:34:59 AEDT+1100'
  145. >>> utc_dt2 = au_dt.astimezone(utc)
  146. >>> utc_dt2.strftime(fmt)
  147. '2006-03-26 21:34:59 UTC+0000'
  148. >>> utc_dt == utc_dt2
  149. True
  150. You can take shortcuts when dealing with the UTC side of timezone
  151. conversions. ``normalize()`` and ``localize()`` are not really
  152. necessary when there are no daylight saving time transitions to
  153. deal with.
  154. >>> utc_dt = datetime.utcfromtimestamp(1143408899).replace(tzinfo=utc)
  155. >>> utc_dt.strftime(fmt)
  156. '2006-03-26 21:34:59 UTC+0000'
  157. >>> au_tz = timezone('Australia/Sydney')
  158. >>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz))
  159. >>> au_dt.strftime(fmt)
  160. '2006-03-27 08:34:59 AEDT+1100'
  161. >>> utc_dt2 = au_dt.astimezone(utc)
  162. >>> utc_dt2.strftime(fmt)
  163. '2006-03-26 21:34:59 UTC+0000'
  164. ``tzinfo`` API
  165. --------------
  166. The ``tzinfo`` instances returned by the ``timezone()`` function have
  167. been extended to cope with ambiguous times by adding an ``is_dst``
  168. parameter to the ``utcoffset()``, ``dst()`` && ``tzname()`` methods.
  169. >>> tz = timezone('America/St_Johns')
  170. >>> normal = datetime(2009, 9, 1)
  171. >>> ambiguous = datetime(2009, 10, 31, 23, 30)
  172. The ``is_dst`` parameter is ignored for most timestamps. It is only used
  173. during DST transition ambiguous periods to resolve that ambiguity.
  174. >>> tz.utcoffset(normal, is_dst=True)
  175. datetime.timedelta(-1, 77400)
  176. >>> tz.dst(normal, is_dst=True)
  177. datetime.timedelta(0, 3600)
  178. >>> tz.tzname(normal, is_dst=True)
  179. 'NDT'
  180. >>> tz.utcoffset(ambiguous, is_dst=True)
  181. datetime.timedelta(-1, 77400)
  182. >>> tz.dst(ambiguous, is_dst=True)
  183. datetime.timedelta(0, 3600)
  184. >>> tz.tzname(ambiguous, is_dst=True)
  185. 'NDT'
  186. >>> tz.utcoffset(normal, is_dst=False)
  187. datetime.timedelta(-1, 77400)
  188. >>> tz.dst(normal, is_dst=False)
  189. datetime.timedelta(0, 3600)
  190. >>> tz.tzname(normal, is_dst=False)
  191. 'NDT'
  192. >>> tz.utcoffset(ambiguous, is_dst=False)
  193. datetime.timedelta(-1, 73800)
  194. >>> tz.dst(ambiguous, is_dst=False)
  195. datetime.timedelta(0)
  196. >>> tz.tzname(ambiguous, is_dst=False)
  197. 'NST'
  198. If ``is_dst`` is not specified, ambiguous timestamps will raise
  199. an ``pytz.exceptions.AmbiguousTimeError`` exception.
  200. >>> tz.utcoffset(normal)
  201. datetime.timedelta(-1, 77400)
  202. >>> tz.dst(normal)
  203. datetime.timedelta(0, 3600)
  204. >>> tz.tzname(normal)
  205. 'NDT'
  206. >>> import pytz.exceptions
  207. >>> try:
  208. ... tz.utcoffset(ambiguous)
  209. ... except pytz.exceptions.AmbiguousTimeError:
  210. ... print('pytz.exceptions.AmbiguousTimeError: %s' % ambiguous)
  211. pytz.exceptions.AmbiguousTimeError: 2009-10-31 23:30:00
  212. >>> try:
  213. ... tz.dst(ambiguous)
  214. ... except pytz.exceptions.AmbiguousTimeError:
  215. ... print('pytz.exceptions.AmbiguousTimeError: %s' % ambiguous)
  216. pytz.exceptions.AmbiguousTimeError: 2009-10-31 23:30:00
  217. >>> try:
  218. ... tz.tzname(ambiguous)
  219. ... except pytz.exceptions.AmbiguousTimeError:
  220. ... print('pytz.exceptions.AmbiguousTimeError: %s' % ambiguous)
  221. pytz.exceptions.AmbiguousTimeError: 2009-10-31 23:30:00
  222. Problems with Localtime
  223. ~~~~~~~~~~~~~~~~~~~~~~~
  224. The major problem we have to deal with is that certain datetimes
  225. may occur twice in a year. For example, in the US/Eastern timezone
  226. on the last Sunday morning in October, the following sequence
  227. happens:
  228. - 01:00 EDT occurs
  229. - 1 hour later, instead of 2:00am the clock is turned back 1 hour
  230. and 01:00 happens again (this time 01:00 EST)
  231. In fact, every instant between 01:00 and 02:00 occurs twice. This means
  232. that if you try and create a time in the 'US/Eastern' timezone
  233. the standard datetime syntax, there is no way to specify if you meant
  234. before of after the end-of-daylight-saving-time transition. Using the
  235. pytz custom syntax, the best you can do is make an educated guess:
  236. >>> loc_dt = eastern.localize(datetime(2002, 10, 27, 1, 30, 00))
  237. >>> loc_dt.strftime(fmt)
  238. '2002-10-27 01:30:00 EST-0500'
  239. As you can see, the system has chosen one for you and there is a 50%
  240. chance of it being out by one hour. For some applications, this does
  241. not matter. However, if you are trying to schedule meetings with people
  242. in different timezones or analyze log files it is not acceptable.
  243. The best and simplest solution is to stick with using UTC. The pytz
  244. package encourages using UTC for internal timezone representation by
  245. including a special UTC implementation based on the standard Python
  246. reference implementation in the Python documentation.
  247. The UTC timezone unpickles to be the same instance, and pickles to a
  248. smaller size than other pytz tzinfo instances. The UTC implementation
  249. can be obtained as pytz.utc, pytz.UTC, or pytz.timezone('UTC').
  250. >>> import pickle, pytz
  251. >>> dt = datetime(2005, 3, 1, 14, 13, 21, tzinfo=utc)
  252. >>> naive = dt.replace(tzinfo=None)
  253. >>> p = pickle.dumps(dt, 1)
  254. >>> naive_p = pickle.dumps(naive, 1)
  255. >>> len(p) - len(naive_p)
  256. 17
  257. >>> new = pickle.loads(p)
  258. >>> new == dt
  259. True
  260. >>> new is dt
  261. False
  262. >>> new.tzinfo is dt.tzinfo
  263. True
  264. >>> pytz.utc is pytz.UTC is pytz.timezone('UTC')
  265. True
  266. Note that some other timezones are commonly thought of as the same (GMT,
  267. Greenwich, Universal, etc.). The definition of UTC is distinct from these
  268. other timezones, and they are not equivalent. For this reason, they will
  269. not compare the same in Python.
  270. >>> utc == pytz.timezone('GMT')
  271. False
  272. See the section `What is UTC`_, below.
  273. If you insist on working with local times, this library provides a
  274. facility for constructing them unambiguously:
  275. >>> loc_dt = datetime(2002, 10, 27, 1, 30, 00)
  276. >>> est_dt = eastern.localize(loc_dt, is_dst=True)
  277. >>> edt_dt = eastern.localize(loc_dt, is_dst=False)
  278. >>> print(est_dt.strftime(fmt) + ' / ' + edt_dt.strftime(fmt))
  279. 2002-10-27 01:30:00 EDT-0400 / 2002-10-27 01:30:00 EST-0500
  280. If you pass None as the is_dst flag to localize(), pytz will refuse to
  281. guess and raise exceptions if you try to build ambiguous or non-existent
  282. times.
  283. For example, 1:30am on 27th Oct 2002 happened twice in the US/Eastern
  284. timezone when the clocks where put back at the end of Daylight Saving
  285. Time:
  286. >>> dt = datetime(2002, 10, 27, 1, 30, 00)
  287. >>> try:
  288. ... eastern.localize(dt, is_dst=None)
  289. ... except pytz.exceptions.AmbiguousTimeError:
  290. ... print('pytz.exceptions.AmbiguousTimeError: %s' % dt)
  291. pytz.exceptions.AmbiguousTimeError: 2002-10-27 01:30:00
  292. Similarly, 2:30am on 7th April 2002 never happened at all in the
  293. US/Eastern timezone, as the clocks where put forward at 2:00am skipping
  294. the entire hour:
  295. >>> dt = datetime(2002, 4, 7, 2, 30, 00)
  296. >>> try:
  297. ... eastern.localize(dt, is_dst=None)
  298. ... except pytz.exceptions.NonExistentTimeError:
  299. ... print('pytz.exceptions.NonExistentTimeError: %s' % dt)
  300. pytz.exceptions.NonExistentTimeError: 2002-04-07 02:30:00
  301. Both of these exceptions share a common base class to make error handling
  302. easier:
  303. >>> isinstance(pytz.AmbiguousTimeError(), pytz.InvalidTimeError)
  304. True
  305. >>> isinstance(pytz.NonExistentTimeError(), pytz.InvalidTimeError)
  306. True
  307. A special case is where countries change their timezone definitions
  308. with no daylight savings time switch. For example, in 1915 Warsaw
  309. switched from Warsaw time to Central European time with no daylight savings
  310. transition. So at the stroke of midnight on August 5th 1915 the clocks
  311. were wound back 24 minutes creating an ambiguous time period that cannot
  312. be specified without referring to the timezone abbreviation or the
  313. actual UTC offset. In this case midnight happened twice, neither time
  314. during a daylight saving time period. pytz handles this transition by
  315. treating the ambiguous period before the switch as daylight savings
  316. time, and the ambiguous period after as standard time.
  317. >>> warsaw = pytz.timezone('Europe/Warsaw')
  318. >>> amb_dt1 = warsaw.localize(datetime(1915, 8, 4, 23, 59, 59), is_dst=True)
  319. >>> amb_dt1.strftime(fmt)
  320. '1915-08-04 23:59:59 WMT+0124'
  321. >>> amb_dt2 = warsaw.localize(datetime(1915, 8, 4, 23, 59, 59), is_dst=False)
  322. >>> amb_dt2.strftime(fmt)
  323. '1915-08-04 23:59:59 CET+0100'
  324. >>> switch_dt = warsaw.localize(datetime(1915, 8, 5, 00, 00, 00), is_dst=False)
  325. >>> switch_dt.strftime(fmt)
  326. '1915-08-05 00:00:00 CET+0100'
  327. >>> str(switch_dt - amb_dt1)
  328. '0:24:01'
  329. >>> str(switch_dt - amb_dt2)
  330. '0:00:01'
  331. The best way of creating a time during an ambiguous time period is
  332. by converting from another timezone such as UTC:
  333. >>> utc_dt = datetime(1915, 8, 4, 22, 36, tzinfo=pytz.utc)
  334. >>> utc_dt.astimezone(warsaw).strftime(fmt)
  335. '1915-08-04 23:36:00 CET+0100'
  336. The standard Python way of handling all these ambiguities is not to
  337. handle them, such as demonstrated in this example using the US/Eastern
  338. timezone definition from the Python documentation (Note that this
  339. implementation only works for dates between 1987 and 2006 - it is
  340. included for tests only!):
  341. >>> from pytz.reference import Eastern # pytz.reference only for tests
  342. >>> dt = datetime(2002, 10, 27, 0, 30, tzinfo=Eastern)
  343. >>> str(dt)
  344. '2002-10-27 00:30:00-04:00'
  345. >>> str(dt + timedelta(hours=1))
  346. '2002-10-27 01:30:00-05:00'
  347. >>> str(dt + timedelta(hours=2))
  348. '2002-10-27 02:30:00-05:00'
  349. >>> str(dt + timedelta(hours=3))
  350. '2002-10-27 03:30:00-05:00'
  351. Notice the first two results? At first glance you might think they are
  352. correct, but taking the UTC offset into account you find that they are
  353. actually two hours appart instead of the 1 hour we asked for.
  354. >>> from pytz.reference import UTC # pytz.reference only for tests
  355. >>> str(dt.astimezone(UTC))
  356. '2002-10-27 04:30:00+00:00'
  357. >>> str((dt + timedelta(hours=1)).astimezone(UTC))
  358. '2002-10-27 06:30:00+00:00'
  359. Country Information
  360. ~~~~~~~~~~~~~~~~~~~
  361. A mechanism is provided to access the timezones commonly in use
  362. for a particular country, looked up using the ISO 3166 country code.
  363. It returns a list of strings that can be used to retrieve the relevant
  364. tzinfo instance using ``pytz.timezone()``:
  365. >>> print(' '.join(pytz.country_timezones['nz']))
  366. Pacific/Auckland Pacific/Chatham
  367. The Olson database comes with a ISO 3166 country code to English country
  368. name mapping that pytz exposes as a dictionary:
  369. >>> print(pytz.country_names['nz'])
  370. New Zealand
  371. What is UTC
  372. ~~~~~~~~~~~
  373. 'UTC' is `Coordinated Universal Time`_. It is a successor to, but distinct
  374. from, Greenwich Mean Time (GMT) and the various definitions of Universal
  375. Time. UTC is now the worldwide standard for regulating clocks and time
  376. measurement.
  377. All other timezones are defined relative to UTC, and include offsets like
  378. UTC+0800 - hours to add or subtract from UTC to derive the local time. No
  379. daylight saving time occurs in UTC, making it a useful timezone to perform
  380. date arithmetic without worrying about the confusion and ambiguities caused
  381. by daylight saving time transitions, your country changing its timezone, or
  382. mobile computers that roam through multiple timezones.
  383. .. _Coordinated Universal Time: https://en.wikipedia.org/wiki/Coordinated_Universal_Time
  384. Helpers
  385. ~~~~~~~
  386. There are two lists of timezones provided.
  387. ``all_timezones`` is the exhaustive list of the timezone names that can
  388. be used.
  389. >>> from pytz import all_timezones
  390. >>> len(all_timezones) >= 500
  391. True
  392. >>> 'Etc/Greenwich' in all_timezones
  393. True
  394. ``common_timezones`` is a list of useful, current timezones. It doesn't
  395. contain deprecated zones or historical zones, except for a few I've
  396. deemed in common usage, such as US/Eastern (open a bug report if you
  397. think other timezones are deserving of being included here). It is also
  398. a sequence of strings.
  399. >>> from pytz import common_timezones
  400. >>> len(common_timezones) < len(all_timezones)
  401. True
  402. >>> 'Etc/Greenwich' in common_timezones
  403. False
  404. >>> 'Australia/Melbourne' in common_timezones
  405. True
  406. >>> 'US/Eastern' in common_timezones
  407. True
  408. >>> 'Canada/Eastern' in common_timezones
  409. True
  410. >>> 'Australia/Yancowinna' in all_timezones
  411. True
  412. >>> 'Australia/Yancowinna' in common_timezones
  413. False
  414. Both ``common_timezones`` and ``all_timezones`` are alphabetically
  415. sorted:
  416. >>> common_timezones_dupe = common_timezones[:]
  417. >>> common_timezones_dupe.sort()
  418. >>> common_timezones == common_timezones_dupe
  419. True
  420. >>> all_timezones_dupe = all_timezones[:]
  421. >>> all_timezones_dupe.sort()
  422. >>> all_timezones == all_timezones_dupe
  423. True
  424. ``all_timezones`` and ``common_timezones`` are also available as sets.
  425. >>> from pytz import all_timezones_set, common_timezones_set
  426. >>> 'US/Eastern' in all_timezones_set
  427. True
  428. >>> 'US/Eastern' in common_timezones_set
  429. True
  430. >>> 'Australia/Victoria' in common_timezones_set
  431. False
  432. You can also retrieve lists of timezones used by particular countries
  433. using the ``country_timezones()`` function. It requires an ISO-3166
  434. two letter country code.
  435. >>> from pytz import country_timezones
  436. >>> print(' '.join(country_timezones('ch')))
  437. Europe/Zurich
  438. >>> print(' '.join(country_timezones('CH')))
  439. Europe/Zurich
  440. Internationalization - i18n/l10n
  441. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  442. Pytz is an interface to the IANA database, which uses ASCII names. The `Unicode Consortium's Unicode Locales (CLDR) <http://cldr.unicode.org>`_
  443. project provides translations. Thomas Khyn's
  444. `l18n <https://pypi.python.org/pypi/l18n>`_ package can be used to access
  445. these translations from Python.
  446. License
  447. ~~~~~~~
  448. MIT license.
  449. This code is also available as part of Zope 3 under the Zope Public
  450. License, Version 2.1 (ZPL).
  451. I'm happy to relicense this code if necessary for inclusion in other
  452. open source projects.
  453. Latest Versions
  454. ~~~~~~~~~~~~~~~
  455. This package will be updated after releases of the Olson timezone
  456. database. The latest version can be downloaded from the `Python Package
  457. Index <http://pypi.python.org/pypi/pytz/>`_. The code that is used
  458. to generate this distribution is hosted on launchpad.net and available
  459. using git::
  460. git clone https://git.launchpad.net/pytz
  461. A mirror on github is also available at https://github.com/stub42/pytz
  462. Announcements of new releases are made on
  463. `Launchpad <https://launchpad.net/pytz>`_, and the
  464. `Atom feed <http://feeds.launchpad.net/pytz/announcements.atom>`_
  465. hosted there.
  466. Bugs, Feature Requests & Patches
  467. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  468. Bugs can be reported using `Launchpad <https://bugs.launchpad.net/pytz>`__.
  469. Issues & Limitations
  470. ~~~~~~~~~~~~~~~~~~~~
  471. - Offsets from UTC are rounded to the nearest whole minute, so timezones
  472. such as Europe/Amsterdam pre 1937 will be up to 30 seconds out. This
  473. is a limitation of the Python datetime library.
  474. - If you think a timezone definition is incorrect, I probably can't fix
  475. it. pytz is a direct translation of the Olson timezone database, and
  476. changes to the timezone definitions need to be made to this source.
  477. If you find errors they should be reported to the time zone mailing
  478. list, linked from http://www.iana.org/time-zones.
  479. Further Reading
  480. ~~~~~~~~~~~~~~~
  481. More info than you want to know about timezones:
  482. http://www.twinsun.com/tz/tz-link.htm
  483. Contact
  484. ~~~~~~~
  485. Stuart Bishop <stuart@stuartbishop.net>