module Utils.Time ( belongToCurrentMonth , timeToDay ) where import Data.Time.Clock import Data.Time.LocalTime import Data.Time.Calendar belongToCurrentMonth :: UTCTime -> IO Bool belongToCurrentMonth time = do timeMonth <- dayMonth <$> timeToDay time actualMonth <- dayMonth <$> (getCurrentTime >>= timeToDay) return (timeMonth == actualMonth) timeToDay :: UTCTime -> IO Day timeToDay time = localDay . (flip utcToLocalTime time) <$> getTimeZone time dayMonth :: Day -> Int dayMonth day = let (_, month, _) = toGregorian day in month