fork download
  1. from calendar import monthrange
  2.  
  3.  
  4. def datetime():
  5. day = 0
  6. month = 0
  7. year = 0
  8. day, month, year = map(int, input("Enter date: ").split(sep='.'))
  9.  
  10. while year not in range(0000, 10000) or len(str(year)) < 4:
  11. year = int(input("Year must be at range of 0000 to 9999 "))
  12. while month not in range(1, 13):
  13. month = int(input("Month must be at range of 1 to 12 "))
  14. while day not in range(1, monthrange(year, month)[1]+1):
  15. day = int(input("Day must be at range of 1 to %s " % monthrange(year, month)[1]))
  16.  
  17. print('%s.%s.%s' % (day, month, year))
  18.  
  19. datetime()
  20.  
Success #stdin #stdout 0.03s 10200KB
stdin
12.12.1999
stdout
Enter date: 12.12.1999