¡@

Home 

python Programming Glossary: tzinfo

How to parse dates with -0400 timezone string in python?

http://stackoverflow.com/questions/1101508/how-to-parse-dates-with-0400-timezone-string-in-python

13 19 19 30 0400' d datetime.datetime 2009 5 13 19 19 30 tzinfo tzoffset None 14400 This way you obtain a datetime object you..

How do I use timezones with a datetime object in python?

http://stackoverflow.com/questions/117514/how-do-i-use-timezones-with-a-datetime-object-in-python

of myTimeZone import datetime re from datetime import tzinfo class myTimeZone tzinfo docstring for myTimeZone def utfoffset.. datetime re from datetime import tzinfo class myTimeZone tzinfo docstring for myTimeZone def utfoffset self dt return timedelta.. int second # dt dt datetime.timedelta hours 1 # dt dt dt.tzinfo.utfoffset myTimeZone return dt.year dt.month dt.day dt.hour..

Python - calendar.timegm() vs. time.mktime()

http://stackoverflow.com/questions/2956886/python-calendar-timegm-vs-time-mktime

and time.mktime Say I have a datetime.datetime with no tzinfo attached shouldn't the two give the same output Don't they both.. passed as a parameter And since the date passed has no tzinfo isn't that number of seconds the same import calendar import..

Python strptime() and timezones?

http://stackoverflow.com/questions/3305413/python-strptime-and-timezones

datetime object that comes back doesn't seem to have any tzinfo associated with it. I did read on this page that apparently.. page that apparently datetime.strptime silently discards tzinfo however I checked the documentation and I can't find anything..

How to convert a python utc datetime to a local datetime using only python standard library?

http://stackoverflow.com/questions/4563272/how-to-convert-a-python-utc-datetime-to-a-local-datetime-using-only-python-stand

timezone def utc_to_local utc_dt return utc_dt.replace tzinfo timezone.utc .astimezone tz None In Python 2 3 import calendar.. def utc_to_local utc_dt local_dt utc_dt.replace tzinfo pytz.utc .astimezone local_tz return local_tz.normalize local_dt..

Python - Convert UTC datetime string to local datetime

http://stackoverflow.com/questions/4770297/python-convert-utc-datetime-string-to-local-datetime

this question If you don't want to provide your own tzinfo objects check out the python dateutil library. It provides tzinfo.. objects check out the python dateutil library. It provides tzinfo implementations on top of a zoneinfo Olson database such that.. # datetime objects are 'naive' by default utc utc.replace tzinfo from_zone # Convert time zone central utc.astimezone to_zone..

How to make an unaware datetime timezone aware in python

http://stackoverflow.com/questions/7065164/how-to-make-an-unaware-datetime-timezone-aware-in-python

15 12 0 pytz.UTC aware datetime.datetime 2011 8 15 8 15 12 tzinfo UTC aware unaware Traceback most recent call last File stdin.. of datetime.today that is timezone aware unaware.replace tzinfo pytz.UTC datetime.datetime 2011 8 15 8 15 12 tzinfo UTC unaware.. tzinfo pytz.UTC datetime.datetime 2011 8 15 8 15 12 tzinfo UTC unaware aware Traceback most recent call last File stdin..

Get the Olson TZ name for the local timezone?

http://stackoverflow.com/questions/7669938/get-the-olson-tz-name-for-the-local-timezone

timezone pytz.timezone name if not hasattr timezone '_tzinfos' continue#skip if some timezone doesn't have info # go thru.. continue#skip if some timezone doesn't have info # go thru tzinfo and see if short name like EDT and offset matches for utcoffset.. matches for utcoffset daylight tzname _ in timezone._tzinfos.iteritems if utcoffset local_offset and tzname localtz local_names.append..

Can't subtract offset-naive and offset-aware datetimes

http://stackoverflow.com/questions/796008/cant-subtract-offset-naive-and-offset-aware-datetimes

awareness from http pytz.sourceforge.net naive dt.replace tzinfo None may have to add time zone conversion as well. share improve..

Converting datetime.date to UTC timestamp in Python

http://stackoverflow.com/questions/8777753/converting-datetime-date-to-utc-timestamp-in-python

float . Python 3.3 datetime.timestamp timestamp dt.replace tzinfo timezone.utc .timestamp Note It is necessary to supply timezone.utc.. 1 And for an aware dt timestamp dt datetime 1970 1 1 tzinfo timezone.utc timedelta seconds 1 Interesting read Epoch time..