blob: e8c7ac15b74f6f8360a4de963491930d5e580a82 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
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 = do
timeZone <- getCurrentTimeZone
return . localDay $ utcToLocalTime timeZone time
dayMonth :: Day -> Int
dayMonth day =
let (_, month, _) = toGregorian day
in month
|