#!/usr/bin/env stack
--stack --install-ghc runghc

{-# LANGUAGE OverloadedStrings #-}

module Timer where

import Data.Time.Clock.POSIX
import Data.Time.Format

{-| Given an integer number of seconds, secToTimestamp
 returns the corresponding time in MM:SS.

>>> secToTimestamp 0
"00:00"
>>> secToTimestamp 1500
"25:00"
>>> secToTimestamp 3000
"50:00"
-}

secToTimestamp :: Int -> String
secToTimestamp = formatTime defaultTimeLocale "%M:%S" . posixSecondsToUTCTime . fromIntegral

main :: IO ()
main = do
    putStrLn $ secToTimestamp 0
    putStrLn $ secToTimestamp 1500
    putStrLn $ secToTimestamp 3000