Is there a built-in library or does anyone have available a function to convert a string timezone such as \"America/New_York\" to a datetime.tzinfo object?
Thanks.
Yes, you need the pytz library:
pytz
import datetime, pytz zoneName = 'America/New_York' now = datetime.datetime.now(pytz.timezone(zoneName))
returns:
datetime.datetime(2011, 3, 16, 1, 39, 33, 87375, tzinfo=<DstTzInfo 'America/New_York' EDT-1 day, 20:00:00 DST>)