kylemsguy

Metric Time Converter

Oct 3rd, 2011
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. def timesec():
  2.     """This function converts the current time into seconds since start of day"""
  3.  
  4.     # import the function to get time as tuple
  5.     from time import localtime
  6.     currtime = localtime()
  7.    
  8.     # convert current time into seconds
  9.     sec = (currtime[3] * 3600) + (currtime[4] * 60) + currtime[5]
  10.  
  11.     return sec
  12.  
  13. def metrictime(sec):
  14.     """This function converts seconds since start of day into metric time as tuple in format ks:sec"""
  15.  
  16.     # Converts time to kiloseconds and seconds
  17.     time = ((sec / 1000), (sec % 1000))
  18.     return time
  19.  
  20. # Calling the functions
  21. time = metrictime(timesec())
  22. print time[0], ":", time[1], "ks"
Advertisement
Add Comment
Please, Sign In to add comment