If this function gets passed only a tzinfo object and no concrete
datetime, the returned display name is indenpendent of daylight savings
time. This can be used for example for selecting timezones, or to set the
time of events that recur across DST changes:
If no localized display name for the timezone is available, and the timezone
is associated with a country that uses only a single timezone, the name of
that country is returned, formatted according to the locale:
The uncommon parameter can be set to True to enable the use of timezone
representations that are not commonly used by the requested locale. For
example, while in French the central European timezone is usually
abbreviated as "HEC", in Canadian French, this abbreviation is not in
common use, so a generic name would be chosen by default:
dt_or_tzinfo - the datetime or tzinfo object that determines
the timezone; if a tzinfo object is used, the
resulting display name will be generic, i.e.
independent of daylight savings time; if None, the
current date in UTC is assumed
width - either "long" or "short"
uncommon - whether even uncommon timezone abbreviations should be used
Note:
If the pattern contains time fields, an AttributeError will be
raised when trying to apply the formatting. This is also true if
the value of date parameter is actually a datetime object,
as this function automatically converts that to a date.
As that example shows, when this function gets passed a
datetime.datetime value, the actual time in the formatted string is
adjusted to the timezone specified by the tzinfo parameter. If the
datetime is "naive" (i.e. it has no associated timezone information),
it is assumed to be in UTC.
These timezone calculations are not performed if the value is of type
datetime.time, as without date information there's no way to determine
what a given time would translate to in a different timezone without
information about whether daylight savings time is in effect or not. This
means that time values are left as-is, and the value of the tzinfo
parameter is only used to display the timezone name if needed:
Note:
If the pattern contains date fields, an AttributeError will be
raised when trying to apply the formatting. This is also true if
the value of time parameter is actually a datetime object,
as this function automatically converts that to a time.
parse_date(string,
locale='de_DE')
Parse a date from a string.
This function uses the date format for the locale as a hint to determine
the order in which the date fields appear in the string.