Advertisement
MrLunk

Untitled

Feb 1st, 2023 (edited)
989
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | Source Code | 0 0
  1. import time
  2.  
  3. def decimal_time():
  4.     timestamp = time.time()
  5.     decimal_time = timestamp % 86400 / 86.4
  6.     hours = int(decimal_time // 100)
  7.     minutes = int((decimal_time % 100) // (100 / 60))
  8.     seconds = int((decimal_time % 100) % (100 / 60) * 60)
  9.     return hours, minutes, seconds
  10.  
  11. while True:
  12.     h, m, s = decimal_time()
  13.     print("Decimal time: {:02d}h{:02d}m{:02d}s".format(h, m, s))
  14.     time.sleep(1)
  15.  
Advertisement
Comments
  • MrLunk
    1 year (edited)
    # text 0.51 KB | 0 0
    1. This script calculates the number of hours, minutes, and seconds in decimal time, and then formats the result as a string in the desired format. The "{:02d}" format specifier is used to display the values with leading zeros, ensuring that the output always has two digits. The time.sleep(1) function call is still used to pause the execution of the script for 1 second, allowing the decimal time to be updated and displayed in real-time.
    2.  
    3. https://en.wikipedia.org/wiki/Decimal_time
    4.  
    5. GReetz,
    6. Peter Lunk aka MrLunk
Add Comment
Please, Sign In to add comment
Advertisement