-
Notifications
You must be signed in to change notification settings - Fork 1
/
time-conversion.hs
38 lines (29 loc) · 916 Bytes
/
time-conversion.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import Control.Applicative
import Control.Monad
import System.IO
main :: IO ()
main = do
time <- getLine
newtime time
newtime x
| x == " " = putStr ""
| otherwise = do
let hours = take 2 x
pmam = drop 8 x
whtime = take 8 x
timewohours = drop 2 whtime
if pmam == "AM"
then do
if hours == "12"
then do
let newhours = "00"
putStr (newhours ++ timewohours)
else do
putStr whtime
else do
if hours == "12"
then do
putStr (hours ++ timewohours)
else do
let newhours = show (read hours + 12)
putStr (newhours ++ timewohours)