#NEWLINE# def get_timezone_name( dt_or_tzinfo = None , width = 'long' , uncommon = False , locale = LC_TIME ) : #NEWLINE# #INDENT# 'Return the localized display name for the given timezone. The timezone\n    may be specified using a ``datetime`` or `tzinfo` object.\n    \n    >>> from pytz import timezone\n    >>> dt = time(15, 30, tzinfo=timezone(\'America/Los_Angeles\'))\n    >>> get_timezone_name(dt, locale=\'en_US\')\n    u\'Pacific Standard Time\'\n    >>> get_timezone_name(dt, width=\'short\', locale=\'en_US\')\n    u\'PST\'\n    \n    If this function gets passed only a `tzinfo` object and no concrete\n    `datetime`,  the returned display name is indenpendent of daylight savings\n    time. This can be used for example for selecting timezones, or to set the\n    time of events that recur across DST changes:\n    \n    >>> tz = timezone(\'America/Los_Angeles\')\n    >>> get_timezone_name(tz, locale=\'en_US\')\n    u\'Pacific Time\'\n    >>> get_timezone_name(tz, \'short\', locale=\'en_US\')\n    u\'PT\'\n    \n    If no localized display name for the timezone is available, and the timezone\n    is associated with a country that uses only a single timezone, the name of\n    that country is returned, formatted according to the locale:\n    \n    >>> tz = timezone(\'Europe/Berlin\')\n    >>> get_timezone_name(tz, locale=\'de_DE\')\n    u\'Deutschland\'\n    >>> get_timezone_name(tz, locale=\'pt_BR\')\n    u\'Hor\\xe1rio Alemanha\'\n    \n    On the other hand, if the country uses multiple timezones, the city is also\n    included in the representation:\n    \n    >>> tz = timezone(\'America/St_Johns\')\n    >>> get_timezone_name(tz, locale=\'de_DE\')\n    u"Kanada (St. John\'s)"\n    \n    The `uncommon` parameter can be set to `True` to enable the use of timezone\n    representations that are not commonly used by the requested locale. For\n    example, while in French the central European timezone is usually\n    abbreviated as "HEC", in Canadian French, this abbreviation is not in\n    common use, so a generic name would be chosen by default:\n    \n    >>> tz = timezone(\'Europe/Paris\')\n    >>> get_timezone_name(tz, \'short\', locale=\'fr_CA\')\n    u\'France\'\n    >>> get_timezone_name(tz, \'short\', uncommon=True, locale=\'fr_CA\')\n    u\'HEC\'\n    \n    :param dt_or_tzinfo: the ``datetime`` or ``tzinfo`` object that determines\n                         the timezone; if a ``tzinfo`` object is used, the\n                         resulting display name will be generic, i.e.\n                         independent of daylight savings time; if `None`, the\n                         current date in UTC is assumed\n    :param width: either "long" or "short"\n    :param uncommon: whether even uncommon timezone abbreviations should be used\n    :param locale: the `Locale` object, or a locale string\n    :return: the timezone display name\n    :rtype: `unicode`\n    :since: version 0.9\n    :see:  `LDML Appendix J: Time Zone Display Names\n            <http://www.unicode.org/reports/tr35/#Time_Zone_Fallback>`_\n    ' #NEWLINE# if ( ( dt_or_tzinfo is None ) or isinstance ( dt_or_tzinfo , ( int , long ) ) ) : #NEWLINE# #INDENT# dt = None #NEWLINE# tzinfo = UTC #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( dt_or_tzinfo , ( datetime , time ) ) : #NEWLINE# #INDENT# dt = dt_or_tzinfo #NEWLINE# if ( dt . tzinfo is not None ) : #NEWLINE# #INDENT# tzinfo = dt . tzinfo #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# tzinfo = UTC #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# dt = None #NEWLINE# tzinfo = dt_or_tzinfo #NEWLINE# #UNINDENT# #UNINDENT# locale = Locale . parse ( locale ) #NEWLINE# if hasattr ( width , 'zone' ) : #NEWLINE# #INDENT# zone = tzinfo . zone #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# zone = tzinfo . tzname ( dt ) #NEWLINE# #UNINDENT# zone = get_global ( 'zone_aliases' ) . get ( zone , zone ) #NEWLINE# info = locale . time_zones . get ( zone , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( width in info ) : #NEWLINE# #INDENT# if ( dt is None ) : #NEWLINE# #INDENT# field = 'generic' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# dst = tzinfo . dst ( dt ) #NEWLINE# if ( dst is None ) : #NEWLINE# #INDENT# field = 'generic' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( dst == 0 ) : #NEWLINE# #INDENT# field = 'standard' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# field = 'daylight' #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( field in info [ width ] ) : #NEWLINE# #INDENT# return info [ width ] [ field ] #NEWLINE# #UNINDENT# #UNINDENT# metazone = get_global ( 'meta_zones' ) . get ( zone ) #NEWLINE# if metazone : #NEWLINE# #INDENT# metazone_info = locale . meta_zones . get ( metazone , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( ( width in metazone_info ) and ( uncommon or metazone_info . get ( 'common' ) ) ) : #NEWLINE# #INDENT# if ( dt is None ) : #NEWLINE# #INDENT# field = 'generic' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# field = ( ( tzinfo . dst ( dt ) and 'daylight' ) or 'standard' ) #NEWLINE# #UNINDENT# if ( field in metazone_info [ width ] ) : #NEWLINE# #INDENT# return metazone_info [ width ] [ field ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( dt is not None ) : #NEWLINE# #INDENT# return get_timezone_gmt ( dt , width = width , locale = locale ) #NEWLINE# #UNINDENT# return get_timezone_location ( dt_or_tzinfo , locale = locale )