aboutsummaryrefslogtreecommitdiff
path: root/src/server/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Utils')
-rw-r--r--src/server/Utils/Time.hs23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/server/Utils/Time.hs b/src/server/Utils/Time.hs
index 0d6ed73..e8c7ac1 100644
--- a/src/server/Utils/Time.hs
+++ b/src/server/Utils/Time.hs
@@ -1,7 +1,6 @@
module Utils.Time
( belongToCurrentMonth
- , getLocalDate
- , Date(..)
+ , timeToDay
) where
import Data.Time.Clock
@@ -10,18 +9,16 @@ import Data.Time.Calendar
belongToCurrentMonth :: UTCTime -> IO Bool
belongToCurrentMonth time = do
- timeMonth <- month <$> getLocalDate time
- actualMonth <- month <$> (getCurrentTime >>= getLocalDate)
+ timeMonth <- dayMonth <$> timeToDay time
+ actualMonth <- dayMonth <$> (getCurrentTime >>= timeToDay)
return (timeMonth == actualMonth)
-getLocalDate :: UTCTime -> IO Date
-getLocalDate time = do
+timeToDay :: UTCTime -> IO Day
+timeToDay time = do
timeZone <- getCurrentTimeZone
- let (y, m, d) = toGregorian . localDay $ utcToLocalTime timeZone time
- return (Date y m d)
+ return . localDay $ utcToLocalTime timeZone time
-data Date = Date
- { year :: Integer
- , month :: Int
- , day :: Int
- }
+dayMonth :: Day -> Int
+dayMonth day =
+ let (_, month, _) = toGregorian day
+ in month