new 'o' feature for date format strings.

svn: r16951
This commit is contained in:
Craig J. Anderson 2011-03-27 21:14:53 +00:00
parent 9b1cb8eecb
commit 4ee9e82163

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,21 @@ class DateFormat(GenericFormat):
else: #found 'dd' else: #found 'dd'
tmp = "0" + day tmp = "0" + day
return tmp[-2:] return tmp[-2:]
def modifier():
print "hi"
ui_mods = [_(""), _("before"), _("after"), _("about"),
_(""), _(""), _("")]
return ui_mods[date.get_modifier()].capitalize()
def modifier_up():
return modifier.upper()
code = "ymdMoO"
code = "ymdM"
upper = "" upper = ""
function = [year, month, day, month_up] function = [year, month, day, month_up, modifier, modifier_up]
return self.generic_format(date, code, upper, function) return self.generic_format(date, code, upper, function)
@ -1447,4 +1458,4 @@ if __name__ == '__main__':
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 !!"