except KeyError:
return {}
+ @property
+ def day_periods(self):
+ """Locale display names for various day periods (not necessarily only AM/PM).
+
+ These are not meant to be used without the relevant `day_period_rules`.
+ """
+ return self._data['day_periods']
+
@property
def days(self):
"""Locale display names for weekdays.
)
-def get_period_names(locale=LC_TIME):
+def get_period_names(width='wide', context='stand-alone', locale=LC_TIME):
"""Return the names for day periods (AM/PM) used by the locale.
>>> get_period_names(locale='en_US')['am']
u'AM'
+ :param width: the width to use, one of "abbreviated", "narrow", or "wide"
+ :param context: the context, either "format" or "stand-alone"
:param locale: the `Locale` object, or a locale string
"""
- return Locale.parse(locale).periods
+ return Locale.parse(locale).day_periods[context][width]
def get_day_names(width='wide', context='format', locale=LC_TIME):