diff options
author | Jonas Borgström <jonas@edgewall.org> | 2007-08-26 13:38:58 +0000 |
---|---|---|
committer | Jonas Borgström <jonas@edgewall.org> | 2007-08-26 13:38:58 +0000 |
commit | d8188245fb04230ca8cd4ad8fafe2f263ffe6b6c (patch) | |
tree | a6e1ac5f1303b63c0ba21b840523db799746b288 /babel/dates.py | |
parent | 533ebf9110ae92f153259cdc6e4f373cc513398f (diff) | |
download | babel-d8188245fb04230ca8cd4ad8fafe2f263ffe6b6c.tar.gz |
Fixed formatting bug with 12-hour clock patterns.
Diffstat (limited to 'babel/dates.py')
-rw-r--r-- | babel/dates.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/babel/dates.py b/babel/dates.py index daea499..92e9c95 100644 --- a/babel/dates.py +++ b/babel/dates.py @@ -706,13 +706,19 @@ class DateTimeFormat(object): elif char == 'a': return self.format_period(char) elif char == 'h': - return self.format(self.value.hour % 12, num) + if self.value.hour % 12 == 0: + return self.format(12, num) + else: + return self.format(self.value.hour % 12, num) elif char == 'H': return self.format(self.value.hour, num) elif char == 'K': - return self.format(self.value.hour % 12 - 1, num) + return self.format(self.value.hour % 12, num) elif char == 'k': - return self.format(self.value.hour + 1, num) + if self.value.hour == 0: + return self.format(24, num) + else: + return self.format(self.value.hour + 1, num) elif char == 'm': return self.format(self.value.minute, num) elif char == 's': @@ -784,7 +790,7 @@ class DateTimeFormat(object): return '%d' % ((self.value.day - 1) / 7 + 1) def format_period(self, char): - period = {0: 'am', 1: 'pm'}[int(self.value.hour > 12)] + period = {0: 'am', 1: 'pm'}[int(self.value.hour >= 12)] return get_period_names(locale=self.locale)[period] def format_frac_seconds(self, num): |