Last active
February 22, 2016 16:11
-
-
Save christian-fei/1536095c610c476fe9ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe_time :: Int -> String | |
describe_time sec = describe_time_rec (0, 0,0,0) sec | |
describe_time_rec :: (Int, Int, Int, Int) -> Int -> String | |
describe_time_rec acc@(days, hours,minutes,seconds) rem | |
| rem >= 86400 = describe_time_rec (days + 1, hours,minutes,seconds) (rem - 86400) | |
| rem >= 3600 = describe_time_rec (days, hours + 1,minutes,seconds) (rem - 3600) | |
| rem >= 60 = describe_time_rec (days, hours,minutes + 1,seconds) (rem - 60) | |
| rem < 60 = describe_time_rec (days, hours, minutes, rem) 0 | |
| rem == 0 = (show days) ++ " DAYS " ++ (show hours) ++ " HOURS " ++ (show minutes) ++ " MINUTES " ++ (show seconds) ++ " SECONDS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment