module Web.Data.Yahoo.Utils (dayAsEpoch, right) where

import Data.Time.Calendar (Day, fromGregorian, diffDays)

dayAsEpoch :: Day -> Integer
dayAsEpoch :: Day -> Integer
dayAsEpoch Day
day = 
    Integer
3600 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* Integer
24 Integer -> Integer -> Integer
forall a. Num a => a -> a -> a
* (Day -> Day -> Integer
diffDays Day
day Day
start)
    where
        start :: Day
        start :: Day
start = Integer -> Int -> Int -> Day
fromGregorian Integer
1970 Int
1 Int
1

right :: (t -> b) -> Either a t -> Either a b
right :: (t -> b) -> Either a t -> Either a b
right t -> b
f (Right t
x) = b -> Either a b
forall a b. b -> Either a b
Right (t -> b
f t
x)
right t -> b
_ (Left a
x)  = a -> Either a b
forall a b. a -> Either a b
Left a
x