Guest User

Untitled

a guest
Aug 21st, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. Regarding simple python date calc
  2. YEARSEC=(12*30*24*3600)
  3. MONTHSEC=(3600*24*30)
  4. DAYSEC=(24*3600)
  5. HOURSEC=3600
  6. MINUTESEC=60
  7.  
  8. year=int(input("Please enter the year in which you were born: "))
  9. month=int(input("Please enter the month you were born: "))
  10. day=int(input("Please enter the day you were born: "))
  11. hour=int(input("Please enter the hour you were born: "))
  12. minute=int(input("Please enter the minute you were born: "))
  13. second=int(input("Please enter the second you were born: "))
  14.  
  15. year_calc=(year*YEARSEC)
  16. month_calc=(month*MONTHSEC)
  17. day_calc=(day*DAYSEC)
  18. hour_calc=(hour*HOURSEC)
  19. minute_calc=(minute*MINUTESEC)
  20. s=(1000000000+year_calc+month_calc+day_calc+hour_calc+minute_calc+second)
  21.  
  22.  
  23. year_num=int((s/YEARSEC))
  24. s=(s-(year_num*YEARSEC))
  25.  
  26.  
  27. month_num=int((s/MONTHSEC))
  28. s=(s-(month_num*MONTHSEC))
  29.  
  30.  
  31. day_num=int((s/DAYSEC))
  32. s=(s-(DAYSEC*day_num))
  33.  
  34. hour_num=int((s/HOURSEC))
  35. s=(s-(HOURSEC*hour_num))
  36.  
  37. minute_num=int((s/MINUTESEC))
  38. s=(s-(MINUTESEC*minute_num))
  39.  
  40.  
  41.  
  42.  
  43. print("You will turn 1 000 000 000 seconds old on: %04d/%02d/%02d %02d:%02d:%02d" %(year_num,month_num,day_num,hour_num,minute_num,s))
  44.  
  45. print("You will turn 1 000 000 000 seconds old on: %04d/%02d/%02d %02d:%02d:%02d" %(year_num,month_num+1,day_num+1,hour_num,minute_num,s))
  46.  
  47. >>> import datetime
  48. >>> birthday = datetime.datetime(1993,11,05,0,0,0)
  49. >>> billion = birthday + datetime.timedelta(seconds=1000000000)
  50. >>> billion.ctime()
  51. 'Mon Jul 14 01:46:40 2025'
Add Comment
Please, Sign In to add comment