#!/usr/bin/env python
#-*- coding=utf-8 -*-
import os
# 定义退出函数
def _exit_(exitstr, exitcode):
print(exitstr)
raw_input('Press enter to exit...')
os._exit(exitcode)
# 定义主函数
def main():
# 获取date字符串
date = raw_input('Input Date(xxx-xx-xx):')
# 解析date字符串
try:
year, month, day = date.strip().split('-')
# 将year、month、day分别转换为整数
year = int(year)
month = int(month)
day = int(day)
# 若无法被split分成三段或无法被转化为整数则报错退出
except ValueError:
_exit_('Type error! The format of date is year-mo-da', 0)
# 解析month,必须大于等于1小于等于12
if month < 1 or month > 12:
_exit_('Month must greater than or equal 1 and less than or equal 12!', 0)
# 解析day,必须大于等于1小于等于指定上限
# 解析每月的day上限
if month in (1, 3, 5, 7, 8, 10, 12):
# 31天月
daytop = 31
elif month in (4, 6, 9, 11):
# 30天月
daytop = 30
elif month == 2:
# 2月
# 年份能被400整除或不能被100整除但能被4整除,则为闰年,29天
if year % 400 == 0 or (year % 100 != 0 and year % 4 == 0):
daytop = 29
# 否则28天
else:
daytop = 28
if day < 1 or day > daytop:
_exit_('Day must greater than or equal 1 and less than or equal %d!' % daytop, 0)
# 若day不为当月最大值,则直接day+1
if day != daytop:
day += 1
# 否则day置1
else:
day = 1
# 若month不为12,则直接month+1
if month != 12:
month += 1
# 否则month置1,year+1
else:
month = 1
year += 1
# 输出结果并退出
_exit_('Next Date: %d-%d-%d' % (year, month, day), 1)
if __name__ == '__main__':
main()