aboutsummaryrefslogtreecommitdiff
path: root/src/server/Utils
diff options
context:
space:
mode:
authorJoris2016-06-26 12:31:24 +0200
committerJoris2016-06-26 12:31:24 +0200
commit9ec84e3a20c767f6525639f58cd22715e302b88d (patch)
treea080552859180707472c1a289080857c0a54fc06 /src/server/Utils
parent5cb36652ccf07c9e0995ebc421a837ad7d258469 (diff)
downloadbudget-9ec84e3a20c767f6525639f58cd22715e302b88d.tar.gz
budget-9ec84e3a20c767f6525639f58cd22715e302b88d.tar.bz2
budget-9ec84e3a20c767f6525639f58cd22715e302b88d.zip
Add an editable date field for punctual payment creation
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