From e58b250024aed23d725dcc75e0fcfe42bb15d154 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Sun, 10 Nov 2024 22:47:35 +0000 Subject: [PATCH] add intToText fn that doesn't use show --- app/Main.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 1787262..732e6ab 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -11,6 +11,9 @@ import Control.Monad.Trans.Resource (runResourceT) import Data.ByteString.Lazy as BS import Data.List as List import Data.Text as T +import Data.Text.Lazy qualified as T (toStrict) +import Data.Text.Lazy.Builder qualified as B +import Data.Text.Lazy.Builder.Int qualified as B import Data.Time.Clock (nominalDiffTimeToSeconds) import Data.Time.Clock.POSIX (posixSecondsToUTCTime, utcTimeToPOSIXSeconds) import Database.Persist.Postgresql (ConnectionPool, ConnectionString, SqlBackend, getPgInterval, runMigration, runSqlPool, withPostgresqlPool) @@ -56,10 +59,13 @@ instance YesodPersist Souplesse where Souplesse pool _ <- getYesod runSqlPool action pool +intToText :: Integral a => a -> T.Text +intToText = T.toStrict . B.toLazyText . B.decimal + getCalendarR :: Handler Html getCalendarR = do - let fTime = T.pack . show . floor . utcTimeToPOSIXSeconds - fDur = T.pack . show . ceiling . nominalDiffTimeToSeconds . getPgInterval + let fTime = intToText . floor . utcTimeToPOSIXSeconds + fDur = intToText . ceiling . nominalDiffTimeToSeconds . getPgInterval (formWidget, _) <- generateFormPost uploadForm sessions' <- runDB Session.recents defaultLayout