Advertisement
Guest User

Untitled

a guest
Jul 28th, 2021
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import datetime
  2.  
  3. print('What do you want to do?')
  4. print('1. Addd the date')
  5. print('2. Subtract the date')
  6. print()
  7.  
  8. choice= int(input('Your choice:'))
  9.  
  10. date = datetime.datetime.now()
  11. print('Today is:',date.year, '-', date.month, '-', date.day)
  12.  
  13. days_= int(input('Enter the number of days here:'))
  14.  
  15. def date_total():
  16. time_delta = datetime.timedelta(days=days_)
  17. date_add= date + time_delta
  18. year = date_add.year
  19. month = date_add.month
  20. day = date_add.day
  21. print('in', days_, 'it will be:', year, '-', month, '-', day)
  22.  
  23. def date_difference():
  24. time_delta = datetime.timedelta(days=days_)
  25. date_subtract = date - time_delta
  26. year = date_subtract.year
  27. month = date_subtract.month
  28. day = date_subtract.day
  29. print(days_, 'days ago was the date:', year, '-', month, '-', day)
  30.  
  31.  
  32.  
  33.  
  34. if choice == 1:
  35. date_total()
  36.  
  37. if choice == 2:
  38. date_difference()
  39.  
  40.  
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement