Skip to content

Commit 0801641

Browse files
committed
Updates
1 parent ef0f7b7 commit 0801641

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

TurboHaskell/HaskellSupport.hs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{-# LANGUAGE TypeFamilies, DataKinds, MultiParamTypeClasses, PolyKinds, TypeApplications, ScopedTypeVariables, TypeInType, ConstraintKinds, TypeOperators, GADTs, UndecidableInstances, StandaloneDeriving, IncoherentInstances, AllowAmbiguousTypes, FunctionalDependencies #-}
2-
module TurboHaskell.HaskellSupport ((|>), isEmpty, whenEmpty, whenNonEmpty, get, set, ifOrEmpty, modify, SetField (..), UpdateField (..), incrementField, decrementField) where
2+
module TurboHaskell.HaskellSupport ((|>), isEmpty, whenEmpty, whenNonEmpty, get, set, ifOrEmpty, modify, SetField (..), UpdateField (..), incrementField, decrementField, isToday, isToday') where
33

44
import ClassyPrelude
55
import Control.Monad (when)
@@ -62,4 +62,15 @@ class SetField (field :: GHC.TypeLits.Symbol) model value | field model -> value
6262
setField :: value -> model -> model
6363

6464
class Record.HasField field model value => UpdateField (field :: GHC.TypeLits.Symbol) model model' value value' | model model' value' -> value where
65-
updateField :: value' -> model -> model'
65+
updateField :: value' -> model -> model'
66+
67+
utcTimeToYearMonthDay :: UTCTime -> (Integer, Int, Int)
68+
utcTimeToYearMonthDay = toGregorian . utctDay -- (year,month,day)
69+
70+
isToday :: UTCTime -> IO Bool
71+
isToday timestamp = do
72+
now <- getCurrentTime
73+
return (isToday' now timestamp)
74+
75+
isToday' :: UTCTime -> UTCTime -> Bool
76+
isToday' currentTime timestamp = utcTimeToYearMonthDay currentTime == utcTimeToYearMonthDay timestamp

0 commit comments

Comments
 (0)