add intToText fn that doesn't use show

This commit is contained in:
Daniel Barlow 2024-11-10 22:47:35 +00:00
parent 1fd0435da6
commit e58b250024

View File

@ -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