new 'o' feature for date format strings.

svn: r16950
This commit is contained in:
Craig J. Anderson 2011-03-27 21:12:13 +00:00
parent 0204ee48e4
commit 92cf3a2901

View File

@ -231,7 +231,8 @@ class DateFormat(GenericFormat):
else: #count == 4 #found 'yyyy' else: #count == 4 #found 'yyyy'
tmp = "000" + year tmp = "000" + year
return tmp[-4:] return tmp[-4:]
def month(char_found = "m"): def month(char_found = "m"):
""" The month part only """ """ The month part only """
month = unicode(date.get_month()) month = unicode(date.get_month())
@ -265,11 +266,18 @@ class DateFormat(GenericFormat):
else: #found 'dd' else: #found 'dd'
tmp = "0" + day tmp = "0" + day
return tmp[-2:] return tmp[-2:]
def modifier():
#ui_mods taken from date.py def lookup_modifier(self, modifier):
ui_mods = ["", _("before"), _("after"), _("about"),
"", "", ""]
return ui_mods[date.get_modifier()].capitalize()
code = "ymdMo"
code = "ymdM" upper = "O"
upper = "" function = [year, month, day, month_up, modifier]
function = [year, month, day, month_up]
return self.generic_format(date, code, upper, function) return self.generic_format(date, code, upper, function)
@ -1446,5 +1454,4 @@ if __name__ == '__main__':
32, 33, 32, 27, 26, 27, 30, 31, 30, 34, 35, 34, 38, 27, 31, 30, 31, 35, 32, 33, 32, 27, 26, 27, 30, 31, 30, 34, 35, 34, 38, 27, 31, 30, 31, 35,
34, 35, 38, 39, 38, 33, 32, 33, 36, 37, 36, 40, 41, 40, 44, 33, 32, 33, 34, 35, 38, 39, 38, 33, 32, 33, 36, 37, 36, 40, 41, 40, 44, 33, 32, 33,
36, 37, 36, 40, 41, 40, 44, 38, 39, 38, 42, 46] else "!! bad !!" 36, 37, 36, 40, 41, 40, 44, 38, 39, 38, 42, 46] else "!! bad !!"