Created
September 26, 2011 22:47
-
-
Save ehabkost/1243630 to your computer and use it in GitHub Desktop.
Challenge: make this code *worse*
This file contains 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
try: | |
datetime.datetime(year+2000 if year < 1000 else year, month, day) | |
print "%i-%i-%i" % (year+2000 if year < 1000 else year, month, day) | |
except ValueError: | |
try: | |
datetime.datetime(year+2000 if year < 1000 else year, day, month) | |
print "%i-%i-%i" % (year+2000 if year < 1000 else year, day, month) | |
except ValueError: | |
try: | |
datetime.datetime(month+2000 if month < 1000 else month, day, year) | |
print "%i-%i-%i" % (month+2000 if month < 1000 else month, day, year) | |
except ValueError: | |
try: | |
datetime.datetime(month+2000 if month < 1000 else month, year, day) | |
print "%i-%i-%i" % (month+2000 if month < 1000 else month, year, day) | |
except ValueError: | |
try: | |
datetime.datetime(day+2000 if day < 1000 else day, month, year) | |
print "%i-%i-%i" % (day+2000 if day < 1000 else day, month, year) | |
except ValueError: | |
try: | |
datetime.datetime(day+2000 if day < 1000 else day, year, month) | |
print "%i-%i-%i" % (day+2000 if day < 1000 else day, year, month) | |
except ValueError: | |
print "%s is illegal" % original_input |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Author credits: https://twitter.com/ikkebr/status/118456266099138560
https://twitter.com/ikkebr/status/118444654877351937