Skip to content

Commit

Permalink
Merge pull request #380 from python-babel/sils/2.3.1
Browse files Browse the repository at this point in the history
2.3.2 release
  • Loading branch information
akx committed Apr 8, 2016
2 parents d36f0fe + 41b7554 commit 9ac2fdf
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
15 changes: 15 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Babel Changelog
===============

Version 2.3.2
-------------

(Bugfix release, released on April 9th)

Bugfixes
~~~~~~~~

* Dates: Period (am/pm) formatting was broken in certain locales (namely zh_TW). Thanks to @jun66j5 for the bug report. (https://github.com/python-babel/babel/issues/378, https://github.com/python-babel/babel/issues/379)

Version 2.3.1
-------------

(Bugfix release because of deployment problems, released on April 8th)

Version 2.3
-----------

Expand Down
2 changes: 1 addition & 1 deletion babel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
negotiate_locale, parse_locale, get_locale_identifier


__version__ = '2.3.1'
__version__ = '2.3.2'
7 changes: 6 additions & 1 deletion babel/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,7 @@ def __getitem__(self, name):
elif char in ('E', 'e', 'c'):
return self.format_weekday(char, num)
elif char == 'a':
# TODO: Add support for the rest of the period formats (a*, b*, B*)
return self.format_period(char)
elif char == 'h':
if self.value.hour % 12 == 0:
Expand Down Expand Up @@ -1381,7 +1382,11 @@ def format_day_of_week_in_month(self):

def format_period(self, char):
period = {0: 'am', 1: 'pm'}[int(self.value.hour >= 12)]
return get_period_names(locale=self.locale)[period]
for width in ('wide', 'narrow', 'abbreviated'):
period_names = get_period_names(context='format', width=width, locale=self.locale)
if period in period_names:
return period_names[period]
raise ValueError('Could not format period %s in %s' % (period, self.locale))

def format_frac_seconds(self, num):
""" Return fractional seconds.
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
# The short X.Y version.
version = '2.3'
# The full version, including alpha/beta/rc tags.
release = '2.3.1'
release = '2.3.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
5 changes: 5 additions & 0 deletions tests/test_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,11 @@ def test_lithuanian_long_format():
)


def test_zh_TW_format():
# Refs GitHub issue #378
assert dates.format_time(datetime(2016, 4, 8, 12, 34, 56), locale='zh_TW') == u'\u4e0b\u534812:34:56'


def test_format_current_moment(monkeypatch):
import datetime as datetime_module
frozen_instant = datetime.utcnow()
Expand Down

0 comments on commit 9ac2fdf

Please sign in to comment.