Advertisement
nher1625

mehh_date_validaion

Apr 30th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. import time
  2.  
  3. constructTimeObject = time.gmtime()
  4. timeObject = constructTimeObject
  5.  
  6. year, month, day,\
  7. hour, minute, second = [
  8.     timeObject[x] for x in range(0,6)
  9. ]
  10.  
  11. date = [year, month, day, hour, minute, second]
  12.  
  13. def isValidDate(date):
  14.     if (1900 < date[0] <= date[0]) and \
  15.        (1 <= date[1] <= 12) and \
  16.        (1 <= date[2] <= 31) and \
  17.        (0 <= date[3] < 24) and \
  18.        (0 <= date[4] < 60) and \
  19.        (0 <= date[5] < 60):
  20.         return 1
  21.  
  22. result = isValidDate(date)
  23.  
  24. if result == 1:
  25.     print("Is a valid date.")
  26. else:
  27.     print("Is an invalid date.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement