gistlib
main.swiftfunc formatTime(timeInSeconds: Int) -> String { let hours = timeInSeconds / 3600 let minutes = (timeInSeconds % 3600) / 60 let seconds = (timeInSeconds % 3600) % 60 return String(format: "%02d:%02d:%02d", hours, minutes, seconds) } // Example usage let timeInSeconds = 3785 let formattedTime = formatTime(timeInSeconds: timeInSeconds) print(formattedTime) // Output: 01:03:05 398 chars13 lines
func formatTime(timeInSeconds: Int) -> String { let hours = timeInSeconds / 3600 let minutes = (timeInSeconds % 3600) / 60 let seconds = (timeInSeconds % 3600) % 60 return String(format: "%02d:%02d:%02d", hours, minutes, seconds) } // Example usage let timeInSeconds = 3785 let formattedTime = formatTime(timeInSeconds: timeInSeconds) print(formattedTime) // Output: 01:03:05
gistlibby LogSnag