Mercurial > babel > old > babel-test
diff babel/dates.py @ 241:9fedbb6f9871
Implement day-of-week-in-month field in date formatting. Closes #50.
author | cmlenz |
---|---|
date | Tue, 07 Aug 2007 20:08:42 +0000 |
parents | e47245bf65b3 |
children | 059b74719f6b |
line wrap: on
line diff
--- a/babel/dates.py +++ b/babel/dates.py @@ -697,6 +697,8 @@ return self.format(self.value.day, num) elif char == 'D': return self.format_day_of_year(num) + elif char == 'F': + return self.format_day_of_week_in_month() elif char in ('E', 'e', 'c'): return self.format_weekday(char, num) elif char == 'a': @@ -774,6 +776,9 @@ def format_day_of_year(self, num): return self.format(self.get_day_of_year(), num) + def format_day_of_week_in_month(self): + return '%d' % ((self.value.day - 1) / 7 + 1) + def format_period(self, char): period = {0: 'am', 1: 'pm'}[int(self.value.hour > 12)] return get_period_names(locale=self.locale)[period]