bitcoin-payment-channel-1.2.0.0: src/PaymentChannel/Internal/Types/Hour.hs
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module PaymentChannel.Internal.Types.Hour where
import PaymentChannel.Internal.Util
import Data.Word
newtype Hour = MkHour { numHours :: Word32 }
deriving
( Eq, Ord, Num, Enum, Real, Integral, Typeable
, Generic, Serialize, ToJSON, FromJSON, NFData
)
instance Show Hour where
show (MkHour h)
| h == 1 = "1 hour"
| otherwise = show h ++ " hours"
toSeconds :: Num a => Hour -> a
toSeconds (MkHour i) = fromIntegral $ i * 3600