fixed errors found with MMM MMMM date format codes.
updated test cases to not use mmm and mmmm as these are localized and the output can differ. still need to put in a test case for mmmm and mmm. svn: r16361
This commit is contained in:
parent
e44dfa291e
commit
b42bc92f33
@ -232,10 +232,10 @@ class DateFormat(GenericFormat):
|
|||||||
tmp = "000" + year
|
tmp = "000" + year
|
||||||
return tmp[-4:]
|
return tmp[-4:]
|
||||||
|
|
||||||
def month():
|
def month(char_found = "m"):
|
||||||
""" The month part only """
|
""" The month part only """
|
||||||
month = unicode(date.get_month())
|
month = unicode(date.get_month())
|
||||||
count = self.__count_chars("m", 4)
|
count = self.__count_chars(char_found, 4)
|
||||||
if month == "0":
|
if month == "0":
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@ -249,6 +249,10 @@ class DateFormat(GenericFormat):
|
|||||||
else: #found 'mmmm'
|
else: #found 'mmmm'
|
||||||
return DateHandler.displayer.long_months[int(month)]
|
return DateHandler.displayer.long_months[int(month)]
|
||||||
|
|
||||||
|
def month_up():
|
||||||
|
return month("M").upper()
|
||||||
|
|
||||||
|
|
||||||
def day():
|
def day():
|
||||||
""" The day part only """
|
""" The day part only """
|
||||||
day = unicode(date.get_day())
|
day = unicode(date.get_day())
|
||||||
@ -263,9 +267,9 @@ class DateFormat(GenericFormat):
|
|||||||
return tmp[-2:]
|
return tmp[-2:]
|
||||||
|
|
||||||
|
|
||||||
code = "ymd"
|
code = "ymdM"
|
||||||
upper = "M"
|
upper = ""
|
||||||
function = [year, month, day]
|
function = [year, month, day, month_up]
|
||||||
|
|
||||||
return self.generic_format(date, code, upper, function)
|
return self.generic_format(date, code, upper, function)
|
||||||
|
|
||||||
@ -1223,7 +1227,7 @@ if __name__ == '__main__':
|
|||||||
)
|
)
|
||||||
#print date_to_test
|
#print date_to_test
|
||||||
|
|
||||||
line_in = "<Z>$ <a>$(<Z>yyy)<b>$(mm){<c>$(d)}{<d>$(yyyy)<e>}<f>$(yy)"
|
line_in = "<Z>$(yyy) <a>$(<Z>Mm)<b>$(mm){<c>$(d)}{<d>$(yyyy)<e>}<f>$(yy)"
|
||||||
consume_str = ConsumableString(line_in)
|
consume_str = ConsumableString(line_in)
|
||||||
|
|
||||||
print line_in
|
print line_in
|
||||||
@ -1244,9 +1248,9 @@ if __name__ == '__main__':
|
|||||||
print tmp
|
print tmp
|
||||||
answer.append(tmp)
|
answer.append(tmp)
|
||||||
print "Good" if answer == [
|
print "Good" if answer == [
|
||||||
"1970 a1970d1970f70",
|
"1970 d1970f70",
|
||||||
"0-09-00 b09",
|
" a99b09",
|
||||||
"0-00-03 c3"
|
" c3"
|
||||||
] else "!! bad !!"
|
] else "!! bad !!"
|
||||||
|
|
||||||
|
|
||||||
@ -1261,9 +1265,9 @@ if __name__ == '__main__':
|
|||||||
print tmp
|
print tmp
|
||||||
answer.append(tmp)
|
answer.append(tmp)
|
||||||
print "Good" if answer == [
|
print "Good" if answer == [
|
||||||
"1970-09-00 a1970b09d1970f70",
|
"1970 a99b09d1970f70",
|
||||||
"1970-00-03 a1970c3d1970f70",
|
"1970 c3d1970f70",
|
||||||
"0-09-03 b09c3"
|
" a99b09c3"
|
||||||
] else "!! bad !!"
|
] else "!! bad !!"
|
||||||
|
|
||||||
|
|
||||||
@ -1277,9 +1281,11 @@ if __name__ == '__main__':
|
|||||||
tmp = main_level_test(consume_str, DateFormat, date_to_test)
|
tmp = main_level_test(consume_str, DateFormat, date_to_test)
|
||||||
print tmp
|
print tmp
|
||||||
answer.append(tmp)
|
answer.append(tmp)
|
||||||
print "Good" if answer == ["1970-09-03 a1970b09c3d1970f70"
|
print "Good" if answer == ["1970 a99b09c3d1970f70"
|
||||||
] else "!! bad !!"
|
] else "!! bad !!"
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.exit()
|
||||||
print
|
print
|
||||||
print
|
print
|
||||||
print "============="
|
print "============="
|
||||||
|
Loading…
Reference in New Issue
Block a user