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