Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from datetime import datetime, timedelta
- def pad(x):
- if int(x) < 10 and len(x)<2:
- return "0"+x
- else:
- return x
- def get_format(date):
- out = ""
- for i in date:
- try:
- int(i)
- out += "x"
- except:
- out += "-"
- return out
- dates = ["01-01-20", "1-2-20", "03-4-20"]
- for i in dates:
- print(i)
- format = get_format(i).split("-")
- month = pad(i.split("-")[0])
- day = pad(i.split("-")[1])
- year = i.split("-")[2]
- dt = datetime.strptime(str("%s-%s-%s"%(month, day, year)), "%m-%d-%y")
- add30 = (dt + timedelta(days=30)).date().strftime("%m-%d-%y")
- output = ""
- for x in range(len(format)):
- if len(format[x]) == 1:
- output += str(int(add30.split("-")[x]))
- else:
- output += add30.split("-")[x]
- output+= "-"
- print(output[:-1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement