module ProjectM36.DataTypes.DateTime where import ProjectM36.Base import ProjectM36.AtomFunctionBody import ProjectM36.AtomFunctionError import qualified Data.HashSet as HS import Data.Time.Clock.POSIX dateTimeAtomFunctions :: AtomFunctions dateTimeAtomFunctions :: AtomFunctions dateTimeAtomFunctions = forall a. (Eq a, Hashable a) => [a] -> HashSet a HS.fromList [ Function { funcName :: FunctionName funcName = FunctionName "dateTimeFromEpochSeconds", funcType :: [AtomType] funcType = [AtomType IntegerAtomType, AtomType DateTimeAtomType], funcBody :: FunctionBody AtomFunctionBodyType funcBody = AtomFunctionBodyType -> FunctionBody AtomFunctionBodyType compiledAtomFunctionBody forall a b. (a -> b) -> a -> b $ \case IntegerAtom Integer epoch:[Atom] _ -> forall (f :: * -> *) a. Applicative f => a -> f a pure (UTCTime -> Atom DateTimeAtom (POSIXTime -> UTCTime posixSecondsToUTCTime (forall a b. (Real a, Fractional b) => a -> b realToFrac Integer epoch))) [Atom] _ -> forall a b. a -> Either a b Left AtomFunctionError AtomFunctionTypeMismatchError }]