METADATA 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. Metadata-Version: 2.1
  2. Name: tzlocal
  3. Version: 2.1
  4. Summary: tzinfo object for the local timezone
  5. Home-page: https://github.com/regebro/tzlocal
  6. Author: Lennart Regebro
  7. Author-email: regebro@gmail.com
  8. License: MIT
  9. Keywords: timezone pytz
  10. Platform: UNKNOWN
  11. Classifier: Development Status :: 5 - Production/Stable
  12. Classifier: License :: OSI Approved :: MIT License
  13. Classifier: Operating System :: Microsoft :: Windows
  14. Classifier: Operating System :: Unix
  15. Classifier: Operating System :: MacOS :: MacOS X
  16. Classifier: Programming Language :: Python :: 2.7
  17. Classifier: Programming Language :: Python :: 3
  18. Classifier: Programming Language :: Python :: 3.6
  19. Classifier: Programming Language :: Python :: 3.7
  20. Classifier: Programming Language :: Python :: 3.8
  21. Requires-Dist: pytz
  22. tzlocal
  23. =======
  24. This Python module returns a ``tzinfo`` object with the local timezone information under Unix and Win-32.
  25. It requires ``pytz``, and returns ``pytz`` ``tzinfo`` objects.
  26. This module attempts to fix a glaring hole in ``pytz``, that there is no way to
  27. get the local timezone information, unless you know the zoneinfo name, and
  28. under several Linux distros that's hard or impossible to figure out.
  29. Also, with Windows different timezone system using pytz isn't of much use
  30. unless you separately configure the zoneinfo timezone name.
  31. With ``tzlocal`` you only need to call ``get_localzone()`` and you will get a
  32. ``tzinfo`` object with the local time zone info. On some Unices you will still
  33. not get to know what the timezone name is, but you don't need that when you
  34. have the tzinfo file. However, if the timezone name is readily available it
  35. will be used.
  36. Supported systems
  37. -----------------
  38. These are the systems that are in theory supported:
  39. * Windows 2000 and later
  40. * Any unix-like system with a ``/etc/localtime`` or ``/usr/local/etc/localtime``
  41. If you have one of the above systems and it does not work, it's a bug.
  42. Please report it.
  43. Please note that if you getting a time zone called ``local``, this is not a bug, it's
  44. actually the main feature of ``tzlocal``, that even if your system does NOT have a configuration file
  45. with the zoneinfo name of your time zone, it will still work.
  46. You can also use ``tzlocal`` to get the name of your local timezone, but only if your system is
  47. configured to make that possible. ``tzlocal`` looks for the timezone name in ``/etc/timezone``, ``/var/db/zoneinfo``,
  48. ``/etc/sysconfig/clock`` and ``/etc/conf.d/clock``. If your ``/etc/localtime`` is a symlink it can also extract the
  49. name from that symlink.
  50. If you need the name of your local time zone, then please make sure your system is properly configured to allow that.
  51. If it isn't configured, tzlocal will default to UTC.
  52. Usage
  53. -----
  54. Load the local timezone:
  55. >>> from tzlocal import get_localzone
  56. >>> tz = get_localzone()
  57. >>> tz
  58. <DstTzInfo 'Europe/Warsaw' WMT+1:24:00 STD>
  59. Create a local datetime:
  60. >>> from datetime import datetime
  61. >>> dt = tz.localize(datetime(2015, 4, 10, 7, 22))
  62. >>> dt
  63. datetime.datetime(2015, 4, 10, 7, 22, tzinfo=<DstTzInfo 'Europe/Warsaw' CEST+2:00:00 DST>)
  64. Lookup another timezone with `pytz`:
  65. >>> import pytz
  66. >>> eastern = pytz.timezone('US/Eastern')
  67. Convert the datetime:
  68. >>> dt.astimezone(eastern)
  69. datetime.datetime(2015, 4, 10, 1, 22, tzinfo=<DstTzInfo 'US/Eastern' EDT-1 day, 20:00:00 DST>)
  70. Maintainer
  71. ----------
  72. * Lennart Regebro, regebro@gmail.com
  73. Contributors
  74. ------------
  75. * Marc Van Olmen
  76. * Benjamen Meyer
  77. * Manuel Ebert
  78. * Xiaokun Zhu
  79. * Cameris
  80. * Edward Betts
  81. * McK KIM
  82. * Cris Ewing
  83. * Ayala Shachar
  84. * Lev Maximov
  85. * Jakub Wilk
  86. * John Quarles
  87. * Preston Landers
  88. * Victor Torres
  89. * Jean Jordaan
  90. * Zackary Welch
  91. * Mickaël Schoentgen
  92. * Gabriel Corona
  93. (Sorry if I forgot someone)
  94. License
  95. -------
  96. * MIT https://opensource.org/licenses/MIT
  97. Changes
  98. =======
  99. 2.1 (2020-05-08)
  100. ----------------
  101. - No changes.
  102. 2.1b1 (2020-02-08)
  103. ------------------
  104. - The is_dst flag is wrong for Europe/Dublin on some Unix releases.
  105. I changed to another way of determining if DST is in effect or not.
  106. - Added support for Python 3.7 and 3.8. Dropped 3.5 although it still works.
  107. 2.0.0 (2019-07-23)
  108. ------------------
  109. - No differences since 2.0.0b3
  110. Major differences since 1.5.1
  111. .............................
  112. - When no time zone configuration can be find, tzlocal now return UTC.
  113. This is a major difference from 1.x, where an exception would be raised.
  114. This change is because Docker images often have no configuration at all,
  115. and the unix utilities will then default to UTC, so we follow that.
  116. - If tzlocal on Unix finds a timezone name in a /etc config file, then
  117. tzlocal now verifies that the timezone it fouds has the same offset as
  118. the local computer is configured with. If it doesn't, something is
  119. configured incorrectly. (Victor Torres, regebro)
  120. - Get timezone via Termux `getprop` wrapper on Android. It's not officially
  121. supported because we can't test it, but at least we make an effort.
  122. (Jean Jordaan)
  123. Minor differences and bug fixes
  124. ...............................
  125. - Skip comment lines when parsing /etc/timezone. (Edward Betts)
  126. - Don't load timezone from current directory. (Gabriel Corona)
  127. - Now verifies that the config files actually contain something before
  128. reading them. (Zackary Welch, regebro)
  129. - Got rid of a BytesWarning (Mickaël Schoentgen)
  130. - Now handles if config file paths exists, but are directories.
  131. - Moved tests out from distributions
  132. - Support wheels
  133. 1.5.1 (2017-12-01)
  134. ------------------
  135. - 1.5 had a bug that slipped through testing, fixed that,
  136. increased test coverage.
  137. 1.5 (2017-11-30)
  138. ----------------
  139. - No longer treats macOS as special, but as a unix.
  140. - get_windows_info.py is renamed to update_windows_mappings.py
  141. - Windows mappings now also contain mappings from deprecated zoneinfo names.
  142. (Preston-Landers, regebro)
  143. 1.4 (2017-04-18)
  144. ----------------
  145. - I use MIT on my other projects, so relicensing.
  146. 1.4b1 (2017-04-14)
  147. ------------------
  148. - Dropping support for Python versions nobody uses (2.5, 3.1, 3.2), adding 3.6
  149. Python 3.1 and 3.2 still works, 2.5 has been broken for some time.
  150. - Ayalash's OS X fix didn't work on Python 2.7, fixed that.
  151. 1.3.2 (2017-04-12)
  152. ------------------
  153. - Ensure closing of subprocess on OS X (ayalash)
  154. - Removed unused imports (jwilk)
  155. - Closes stdout and stderr to get rid of ResourceWarnings (johnwquarles)
  156. - Updated Windows timezones (axil)
  157. 1.3 (2016-10-15)
  158. ----------------
  159. - #34: Added support for /var/db/zoneinfo
  160. 1.2.2 (2016-03-02)
  161. ------------------
  162. - #30: Fixed a bug on OS X.
  163. 1.2.1 (2016-02-28)
  164. ------------------
  165. - Tests failed if TZ was set in the environment. (EdwardBetts)
  166. - Replaces os.popen() with subprocess.Popen() for OS X to
  167. handle when systemsetup doesn't exist. (mckabi, cewing)
  168. 1.2 (2015-06-14)
  169. ----------------
  170. - Systemd stores no time zone name, forcing us to look at the name of the file
  171. that localtime symlinks to. (cameris)
  172. 1.1.2 (2014-10-18)
  173. ------------------
  174. - Timezones that has 3 items did not work on Mac OS X.
  175. (Marc Van Olmen)
  176. - Now doesn't fail if the TZ environment variable isn't an Olsen time zone.
  177. - Some timezones on Windows can apparently be empty (perhaps the are deleted).
  178. Now these are ignored.
  179. (Xiaokun Zhu)
  180. 1.1.1 (2014-01-29)
  181. ------------------
  182. - I forgot to add Etc/UTC as an alias for Etc/GMT.
  183. 1.1 (2014-01-28)
  184. ----------------
  185. - Adding better support for OS X.
  186. - Added support to map from tzdata/Olsen names to Windows names.
  187. (Thanks to Benjamen Meyer).
  188. 1.0 (2013-05-29)
  189. ----------------
  190. - Fixed some more cases where spaces needs replacing with underscores.
  191. - Better handling of misconfigured /etc/timezone.
  192. - Better error message on Windows if we can't find a timezone at all.
  193. 0.3 (2012-09-13)
  194. ----------------
  195. - Windows 7 support.
  196. - Python 2.5 supported; because it only needed a __future__ import.
  197. - Python 3.3 tested, it worked.
  198. - Got rid of relative imports, because I don't actually like them,
  199. so I don't know why I used them in the first place.
  200. - For each Windows zone, use the default zoneinfo zone, not the last one.
  201. 0.2 (2012-09-12)
  202. ----------------
  203. - Python 3 support.
  204. 0.1 (2012-09-11)
  205. ----------------
  206. - Initial release.