From: Aarni Koskela Date: Sun, 14 Feb 2016 17:37:40 +0000 (+0200) Subject: Use `day_periods` for `get_period_names` X-Git-Tag: 2.3.1~6^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1a0a2310bbc7b9c926e972076bffbd626d8081c;p=thirdparty%2Fbabel.git Use `day_periods` for `get_period_names` --- diff --git a/babel/core.py b/babel/core.py index 1c6c98a2..f6bc25f1 100644 --- a/babel/core.py +++ b/babel/core.py @@ -619,6 +619,14 @@ class Locale(object): 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. diff --git a/babel/dates.py b/babel/dates.py index 0ba2a2f5..65c59735 100644 --- a/babel/dates.py +++ b/babel/dates.py @@ -247,15 +247,17 @@ class TimezoneTransition(object): ) -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):