Download Shareware and Freeware Software for Windows, Linux, Macintosh, PDA

line Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

Serving Software Downloads in 956 Categories, Downloaded 50.076.898 Times

PyTZ for Linux 2010b

Company: Stuart Bishop
Date Added: June 22, 2013  |  Visits: 428

PyTZ for Linux

Report Broken Link
Printer Friendly Version


Product Homepage
Download (33 downloads)



It's a library that allows accurate and cross platform timezone calculations using Python 2.3 or higher.<br /><br />PyTZ brings the Olson tz database into Python. It's a library that 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, which you can read more about in the Python Library Reference (datetime.tzinfo).<br /><br />Amost all (over 540) of the Olson timezones are supported [*].<br /><br />Note that this library differs from the documented Python API for tzinfo implementations; if you want to create local wallclock times you need to use the localize() method documented in this document. In addition, if you perform date arithmetic on local times that cross DST boundaries, the results may be in an incorrect timezone (ie. subtract 1 minute from 2002-10-27 1:00 EST and you get 2002-10-27 0:59 EST instead of the correct 2002-10-27 1:59 EDT). A normalize() method is provided to correct this. Unfortunatly these issues cannot be resolved without modifying the Python datetime implementation.<br /><br />Installation:<br /><br />This package can either be installed from a .egg file using setuptools, or from the tarball using the standard Python distutils.<br /><br />If you are installing from a tarball, run the following command as an administrative user:<br /><br />python setup.py install<br /><br />If you are installing using setuptools, you don???*a*?t even need to download anything as the latest version will be downloaded for you from the Python package index:<br /><br />easy_install --upgrade pytz<br /><br />If you already have the .egg file, you can use that too:<br /><br />easy_install pytz-2008g-py2.6.egg<br /><br />Example & Usage:<br /><br />>>> from datetime import datetime, timedelta<br />>>> from pytz import timezone<br />>>> import pytz<br />>>> utc = pytz.utc<br />>>> utc.zone<br />'UTC'<br />>>> eastern = timezone('US/Eastern')<br />>>> eastern.zone<br />'US/Eastern'<br />>>> amsterdam = timezone('Europe/Amsterdam')<br />>>> fmt = '%Y-%m-%d %H:%M:%S %Z%z'<br /><br />This library only supports two ways of building a localized time. The first is to use the .localize() method provided by the pytz library. This is used to localize a naive datetime (datetime with no timezone information):<br /><br />>>> loc_dt = eastern.localize(datetime(2002, 10, 27, 6, 0, 0))<br />>>> print loc_dt.strftime(fmt)<br />2002-10-27 06:00:00 EST-0500<br /><br />The second way of building a localized time is by converting an existing localized time using the standard .astimezone() method:<br /><br />>>> ams_dt = loc_dt.astimezone(amsterdam)<br />>>> ams_dt.strftime(fmt)<br />'2002-10-27 12:00:00 CET+0100'<br /><br />Unfortunately using the tzinfo argument of the standard datetime constructors ???*????*a*?does not work???*a*????*a*? with pytz for many timezones.<br /><br />>>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=amsterdam).strftime(fmt)<br />'2002-10-27 12:00:00 AMT+0020'<br /><br />It is safe for timezones without daylight savings trasitions though, such as UTC:<br /><br />>>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=pytz.utc).strftime(fmt)<br />'2002-10-27 12:00:00 UTC+0000'<br /><br />The preferred way of dealing with times is to always work in UTC, converting to localtime only when generating output to be read by humans.<br /><br />>>> utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc)<br />>>> loc_dt = utc_dt.astimezone(eastern)<br />>>> loc_dt.strftime(fmt)<br />'2002-10-27 01:00:00 EST-0500'<br /><br />This library also allows you to do date arithmetic using local times, although it is more complicated than working in UTC as you need to use the normalize method to handle daylight savings time and other timezone transitions. In this example, loc_dt is set to the instant when daylight savings time ends in the US/Eastern timezone.<br /><br />>>> before = loc_dt - timedelta(minutes=10)<br />>>> before.strftime(fmt)<br />'2002-10-27 00:50:00 EST-0500'<br />>>> eastern.normalize(before).strftime(fmt)<br />'2002-10-27 01:50:00 EDT-0400'<br />>>> after = eastern.normalize(before + timedelta(minutes=20))<br />>>> after.strftime(fmt)<br />'2002-10-27 01:10:00 EST-0500'<br /><br />Creating localtimes is also tricky, and the reason why working with local times is not recommended. Unfortunately, you cannot just pass a ???*?tzinfo???*a*? argument when constructing a datetime (see the next section for more details)<br /><br />>>> dt = datetime(2002, 10, 27, 1, 30, 0)<br />>>> dt1 = eastern.localize(dt, is_dst=True)<br />>>> dt1.strftime(fmt)<br />'2002-10-27 01:30:00 EDT-0400'<br />>>> dt2 = eastern.localize(dt, is_dst=False)<br />>>> dt2.strftime(fmt)<br />'2002-10-27 01:30:00 EST-0500'<br /><br />Converting between timezones also needs special attention. This also needs to use the normalize method to ensure the conversion is correct.<br /><br />>>> utc_dt = utc.localize(datetime.utcfromtimestamp(1143408899))<br />>>> utc_dt.strftime(fmt)<br />'2006-03-26 21:34:59 UTC+0000'<br />>>> au_tz = timezone('Australia/Sydney')<br />>>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz))<br />>>> au_dt.strftime(fmt)<br />'2006-03-27 08:34:59 EST+1100'<br />>>> utc_dt2 = utc.normalize(au_dt.astimezone(utc))<br />>>> utc_dt2.strftime(fmt)<br />'2006-03-26 21:34:59 UTC+0000'<br /><br />You can take shortcuts when dealing with the UTC side of timezone conversions. Normalize and localize are not really necessary when there are no daylight savings time transitions to deal with.<br /><br />>>> utc_dt = datetime.utcfromtimestamp(1143408899).replace(tzinfo=utc)<br />>>> utc_dt.strftime(fmt)<br />'2006-03-26 21:34:59 UTC+0000'<br />>>> au_tz = timezone('Australia/Sydney')<br />>>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz))<br />>>> au_dt.strftime(fmt)<br />'2006-03-27 08:34:59 EST+1100'<br />>>> utc_dt2 = au_dt.astimezone(utc)<br />>>> utc_dt2.strftime(fmt)<br />'2006-03-26 21:34:59 UTC+0000'<br /><br />#md5=5c80c010c1f4a6c69d6e835e89c03afe<br /><br />#md5=f976fb6343f58a618e86e05bbfb0c20e

Requirements: No special requirements
Platforms: *nix, Linux
Keyword: 2010b Datetime Daylight Import Library Linux Loc Local Localize Localized Method Normalize Python Pytz Pytz Linux Savings Times Timezone Timezones Utc
Users rating: 0/10

License: Freeware Size: 245.76 KB
USER REVIEWS
More Reviews or Write Review


PYTZ FOR LINUX RELATED
Development Editors  -  AMNSoft Library Path Editor 3.00.01
Now you can backup your current library path, or, use backup as another path for some projects or another user, export and import library path. Go to Control Panel to find this applet. Get AMNSoft Library Path Editor and give it a try to fully...
 
Programming  -  Github::Import for Linux 0.05
Github::Import is a Perl module that provides a way to import a git repository into http://github.com. SYNOPSIS # You can see your token at https://github.com/account % cd some_project_in_git % github-import...
20.48 KB  
Multimedia & Graphics  -  Read Local Lyrics 1.1
Read Local Lyrics is a little Python script works as a lyrics plugin. If to some audio file, a corresponding ".txt" file can be found in the same folder, this is taken as the lyrics of the song.. Download KDE-Apps.org Community Portal for KDE...
30.72 KB  
Libraries  -  Python Imaging Library 1.1.5
The Python Imaging Library (PIL) adds image processing capabilities to your Python interpreter. This library supports many file formats, and provides powerful image processing and graphics capabilities. The current free version is PIL 1.1.5,...
430.08 KB  
Programming  -  Pyjamas for Linux 0.7pre1
Pyjamas is a toolkit and library designed to enable writing AJAX applications in Python. Pyjamas is based on Google's GWT, which does the same thing for Java. ike GWT, pyjamas involves the translation of the application and libraries...
1.76 MB  
Science  -  TinyGPX 30
Application for geocaching or waymarking that allows you to import GPX or LOC files for editing. You can print out cheat sheets to take on the trail, export to KML or HTML, and send the data to your handheld GPS unit.
19.78 MB  
File Utilities  -  cpufrequtils 5
cpufrequtils project consists of a library which offers an unified access method for userspace tools and programs to the CPU frequency and voltage scaling (cpufreq) subsystem in the Linux kernel, the "cpufreq-info" and "cpufreq-set" to
419.84 KB  
3D Graphic Tools  -  PIL 1.1.5
The Python Imaging Library (PIL) adds image processing capabilities to your Python interpreter. This library supports many file formats, and provides powerful image processing and graphics capabilities. This source kit has been built and tested...
430.08 KB  
Modules  -  PyUI 0.95
PyUI is a user interface library written entirely in the high-level language python. It has a modular implementation that allows the drawing and event input to be performed by pluggable "renderers". This makes PyUI very portable and scalable. It...
 
Programming  -  PySQLPool 0.3.7
PySQLPool is a MySQL Connection Pooling library that can be used with the MySQLDB Python bindings. Part of the PySQLPool is the MySQL Query class that handles all the thread safe connection locking, connection management in association...
10.24 KB  
NEW DOWNLOADS IN LINUX SOFTWARE, PROGRAMMING
Linux Software  -  EasyEDA PCB Designer for Linux 2.0.0
EasyEDA, a great web based EDA(Electronics Design Automation) tool, online PCB tool, online PCB software for electronics engineers, educators, students, makers and enthusiasts. Theres no need to install any software. Just open EasyEDA in any...
34.4 MB  
Linux Software  -  wpCache® WordPress HTTP Cache 1.9
wpCache® is a high-performance, distributed object, caching system application, generic in nature, but intended for use in speeding up dynamic web applications, by decreasing database load time. wpCache® decreases dramatically the page...
3.51 MB  
Linux Software  -  Polling Autodialer Software 3.4
ICTBroadcast Auto Dialer software has a survey campaign for telephone surveys and polls. This auto dialer software automatically dials a list of numbers and asks them a set of questions that they can respond to, by using their telephone keypad....
488 B  
Linux Software  -  Total Video Converter Mac Free 3.5.5
Total Video Converter Mac Free developed by EffectMatrix Ltd is the official legal version of Total Video Converter which was a globally recognized brand since 2006. Total Video Converter Mac Free is a free but powerful all-in-one video...
17.7 MB  
Linux Software  -  Skeith mod_log_sql Analyzer 2.10beta2
Skeith is a php based front end for analyzing logs for Apache using mod_log_sql.
47.5 KB  
Programming  -  Cedalion for Linux 0.2.6
Cedalion is a programming language that allows its users to add new abstractions and define (and use) internal DSLs. Its innovation is in the fact that it uses projectional editing to allow the new abstractions to have no syntactic limitations.
471.04 KB  
Programming  -  Math::GMPf 0.29
Math::GMPf - perl interface to the GMP library's floating point (mpf) functions.
30.72 KB  
Programming  -  Net::Wire10 1.08
Net::Wire10 is a Pure Perl connector that talks to Sphinx, MySQL and Drizzle servers. Net::Wire10 implements the low-level network protocol, alias the MySQL wire protocol version 10, necessary for talking to one of the aforementioned...
30.72 KB  
Programming  -  logilab-common 0.56.2
a bunch of modules providing low level functionnalities shared among some python projects devel Please note that some of the modules have some extra dependencies. For instance, logilab.common.db will require a db-api 2.0 compliant...
174.08 KB  
Programming  -  OpenSSL for linux 1.0.0a
The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implementing the Secure Sockets Layer (SSL v2/v3) and Transport Layer Security (TLS v1) protocols as well as a...
3.83 MB