Fixing dates - 2
from date import test_date
import re
def fix_date2(date):
return re.sub(r'-(\d)-', r'-0\1', date)
test_date(fix_date2)
Output:
old: 2010-07-5
new: 2010-07-5
expected: 2010-07-05
old: 2010-11-5
new: 2010-11-5
expected: 2010-11-05
old: 2010-7-15
new: 2010-0715
expected: 2010-07-15
old: 2010-7-5
new: 2010-075
expected: 2010-07-05