priore

CMTime extension to retrieve Seconds and time in String format (HH:mm:ss)

Oct 8th, 2020
1,450
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extension CMTime {
  2.    
  3.     var seconds: Int {
  4.         return Int(CMTimeGetSeconds(self))
  5.     }
  6.  
  7.     var string: String {
  8.         let value = self.seconds
  9.         let hours = (value % 86400) / 3600
  10.         let minutes = (value % 3600) / 60
  11.         let seconds = (value % 3600) % 60
  12.         return String(format: "%02d:%02d:%02d", hours, minutes, seconds)
  13.     }
  14. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×