diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2015-03-16 22:21:41 +0000 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2015-03-16 22:21:56 +0000 |
commit | a3ddda1f63d251cd3911d3d0625622ed2adf45b4 (patch) | |
tree | 7ae60f80de5402c3d99cbcae3240290d769fe9d5 | |
parent | 1d4a9a462f6eb42e607a502b288aeaf402f84e98 (diff) | |
download | sariulclocks-a3ddda1f63d251cd3911d3d0625622ed2adf45b4.tar.gz |
calculate cookie expiry time to be after the end of current school day
-rw-r--r-- | src/Types/Session.hs | 18 | ||||
-rw-r--r-- | src/sariulclocks.hs | 1 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/Types/Session.hs b/src/Types/Session.hs index 25df029..6307a48 100644 --- a/src/Types/Session.hs +++ b/src/Types/Session.hs @@ -3,15 +3,27 @@ module Types.Session where import Types.Classes import Types.Clocks import Network.CGI.Cookie -import System.Time (CalendarTime) +import System.Time data Session = Session { currentClass :: Maybe Class , currentClock :: Clock } deriving (Eq) -makeClassCookie :: CalendarTime -> Session -> Cookie +-- If we were using a proper monad stack, this should be of type App +-- Cookie where it uses the reader monad to get the CalendarTime and +-- maybe the session from the state monad + +makeClassCookie :: ClockTime -> Session -> Cookie makeClassCookie now session = undefined -makeClockCookie :: CalendarTime -> Session -> Cookie +makeClockCookie :: ClockTime -> Session -> Cookie makeClockCookie now session = undefined + +endOfSchoolDay :: ClockTime -> CalendarTime +endOfSchoolDay now = (toUTCTime . addToClockTime noTimeDiff { tdHour = hoursTilEndOfDay }) now + where + koreanTime = ((toUTCTime . addToClockTime noTimeDiff { tdHour = 9 }) now) + { ctTZ = 9 * 60 * 60 + , ctTZName = "KST"} + hoursTilEndOfDay = 18 - ctHour koreanTime diff --git a/src/sariulclocks.hs b/src/sariulclocks.hs index ee8dba9..cf136c9 100644 --- a/src/sariulclocks.hs +++ b/src/sariulclocks.hs @@ -46,7 +46,6 @@ cgiMain = do _ -> zeroScores clockTime <- liftIO getClockTime - calendarTime <- liftIO . toCalendarTime $ clockTime output $ templateInject htmlTemplate (page scores) |