Created
May 11, 2019 20:16
-
-
Save jatinsharrma/f36830c5ec08afe43c94ad5e21cd74ca to your computer and use it in GitHub Desktop.
Write a program to generate and display the next date of a given date.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def next_date(day,month,year): | |
| flag = False | |
| day = day + 1 | |
| if year%4 == 0: | |
| if year % 100: | |
| if year%400 == 0: | |
| flag = True | |
| else: | |
| flag = False | |
| else : | |
| flag = True | |
| else : | |
| flag = False | |
| if month in [1,3,5,7,9,11]: | |
| if day >31: | |
| day = 1 | |
| month = month + 1 | |
| elif month in [4,6,8,10,12]: | |
| if day >30: | |
| day = 1 | |
| month = month + 1 | |
| elif month == 2 : | |
| if flag == True : | |
| if day > 29: | |
| day = 1 | |
| month = month + 1 | |
| else : | |
| if day >28 : | |
| day = 1 | |
| month = month + 1 | |
| if month > 12: | |
| month = 1 | |
| year = year + 1 | |
| print(day,"-",month,"-",year) | |
| next_date(31,11,2019) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment