返回固定的日期格式,返回的格式为 年,日,月,格式可以自己更改
- def coverdate(self,year,month,day):
- year = int(year)
- month = int(month)
- day = int(day)
- if year % 4 == 0: #判断是否是闰年
- if day == 29 and month == 2: #2月特殊处理
- wantday =str(year) + "1" + "3"
- elif day == 31 and month == 12: #12月特殊处理
- wantday = str(year+1) + “1” +“1”
- elif day == 31: #31天的月份
- for i in [1,3,5,7,8,10]:
- if i == month:
- wantday = str(year)+"1" +str(month+1)
- elif day == 30: #30天的月份
- for i in [4,6,9,11]: #31天的月份也包含30天
- if i == month:
- wantday = str(yar)+"1" + str(month+1)
- else:
- wantday = str(year)+ str(day+1) + str(month)
- else: #普通天处理
- wantday = str(year) + str(day+1) + str(month)
- else:
- if day == 28 and month == 2:
- wantday = str(year)+"1" +"3"
- elif day == 31 and mont == 12:
- wantday = str(year+1) + “1” +“1”
- elif day == 31:
- for i in [1,3,5,7,8,10]:
- if i == month:
- wantday = str(year)+"1" +str(month+1)
- elif day == 30:
- for i in [4,6,9,11]:
- if i == month:
- wantday = str(yar)+"1" + str(month+1)
- else:
- wantday = str(year)+ str(day+1) + str(month)
- else:
- wantday = str(year) + str(day+1) + str(month)