Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert seconds to HH:MM:SS
#1
Need to convert seconds to HH:MM:SS
I found this post listed in the code remarks not to sure on how to modify.
Any help appreciated!

Function Secs_To_HHMMSS
Code:
Copy      Help
/ Secs_To_HHMMSS
;;; Convert number of seconds to HH:MM:SS  
int hh mm ss cnt
cnt = 3665    ;; seconds

;; below is code from post:  "https://www.quickmacros.com/forum/showthread.php?tid=4472&highlight=SECONDS+TO+HOURS"
;;; Not to sure how to implement or if it's correct formula for this purpose...  
int ns=60*60+(60*60)+61    ;; original was "int ns=60*60*24+(60*60)+61" I removed the *24 for the days.
out TimeSpanToStr(TimeSpanFromParts(0 0 0 ns))
#2
here are 4 ways
Code:
Copy      Help
int t = 3665    ;; seconds
;;#1 using string format
_s.format("%02i:%02i:%02i" t/3600 t/60%60 t%60);
out _s
;;#2 using  F Format
out F"{t/3600%%02i}:{t/60%60%%02i}:{t%60%%02i}"
;;#3 using TimeSpanToStr(TimeSpanFromParts())
out TimeSpanToStr(TimeSpanFromParts(0 0 0 t))
;;#4 using TimeSpanToStr
out TimeSpanToStr(t*10000000L)
#3
Ah! Thank you once again Kevin.
Option 1 or 2 will do the trick.
Smile


Forum Jump:


Users browsing this thread: 1 Guest(s)