module Data.HodaTime.Offset
(
Offset
,empty
,fromSeconds
,fromMinutes
,fromHours
,seconds
,minutes
,hours
,addClamped
,minusClamped
)
where
import Data.HodaTime.Offset.Internal
import Data.HodaTime.Internal (secondsFromMinutes, secondsFromHours, clamp, hoursFromSecs, minutesFromSecs, secondsFromSecs)
minOffsetHours :: Num a => a
minOffsetHours :: forall a. Num a => a
minOffsetHours = a -> a
forall a. Num a => a -> a
negate a
forall a. Num a => a
maxOffsetHours
maxOffsetMinutes :: Num a => a
maxOffsetMinutes :: forall a. Num a => a
maxOffsetMinutes = a
forall a. Num a => a
maxOffsetHours a -> a -> a
forall a. Num a => a -> a -> a
* a
60
minOffsetMinutes :: Num a => a
minOffsetMinutes :: forall a. Num a => a
minOffsetMinutes = a -> a
forall a. Num a => a -> a
negate a
forall a. Num a => a
maxOffsetMinutes
fromMinutes :: Integral a => a -> Offset
fromMinutes :: forall a. Integral a => a -> Offset
fromMinutes = Int -> Offset
Offset (Int -> Offset) -> (a -> Int) -> a -> Offset
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Int
forall a b. (Integral a, Num b) => a -> b
secondsFromMinutes (a -> Int) -> (a -> a) -> a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a -> a -> a
forall a. Ord a => a -> a -> a -> a
clamp a
forall a. Num a => a
minOffsetMinutes a
forall a. Num a => a
maxOffsetMinutes
fromHours :: Integral a => a -> Offset
fromHours :: forall a. Integral a => a -> Offset
fromHours = Int -> Offset
Offset (Int -> Offset) -> (a -> Int) -> a -> Offset
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Int
forall a b. (Integral a, Num b) => a -> b
secondsFromHours (a -> Int) -> (a -> a) -> a -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a -> a -> a
forall a. Ord a => a -> a -> a -> a
clamp a
forall a. Num a => a
minOffsetHours a
forall a. Num a => a
maxOffsetHours
seconds :: Functor f => (Int -> f Int) -> Offset -> f Offset
seconds :: forall (f :: * -> *).
Functor f =>
(Int -> f Int) -> Offset -> f Offset
seconds Int -> f Int
f (Offset Int
secs) = (Int -> Offset) -> (Int -> f Int) -> Int -> f Offset
forall (f :: * -> *) b a.
(Functor f, Num b, Integral b) =>
(b -> a) -> (Int -> f Int) -> b -> f a
secondsFromSecs Int -> Offset
forall a. Integral a => a -> Offset
fromSeconds Int -> f Int
f Int
secs
{-# INLINE seconds #-}
minutes :: Functor f => (Int -> f Int) -> Offset -> f Offset
minutes :: forall (f :: * -> *).
Functor f =>
(Int -> f Int) -> Offset -> f Offset
minutes Int -> f Int
f (Offset Int
secs) = (Int -> Offset) -> (Int -> f Int) -> Int -> f Offset
forall (f :: * -> *) b a.
(Functor f, Num b, Integral b) =>
(b -> a) -> (Int -> f Int) -> b -> f a
minutesFromSecs Int -> Offset
forall a. Integral a => a -> Offset
fromSeconds Int -> f Int
f Int
secs
{-# INLINE minutes #-}
hours :: Functor f => (Int -> f Int) -> Offset -> f Offset
hours :: forall (f :: * -> *).
Functor f =>
(Int -> f Int) -> Offset -> f Offset
hours Int -> f Int
f (Offset Int
secs) = (Int -> Offset) -> (Int -> f Int) -> Int -> f Offset
forall (f :: * -> *) b a.
(Functor f, Num b, Integral b) =>
(b -> a) -> (Int -> f Int) -> b -> f a
hoursFromSecs Int -> Offset
forall a. Integral a => a -> Offset
fromSeconds Int -> f Int
f Int
secs
{-# INLINE hours #-}