mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-12 04:08:29 +01:00
Get rid of hours display in date diffs (fixes #217)
Pinging @chrisdone and @juhp
This commit is contained in:
parent
bcf86a1d40
commit
e5a7e9b2e8
@ -8,8 +8,6 @@ module Handler.Home
|
||||
) where
|
||||
|
||||
import Data.Time.Clock
|
||||
import Formatting
|
||||
import Formatting.Time
|
||||
import Import
|
||||
import Stackage.Database
|
||||
import Yesod.GitRepo (grContent)
|
||||
@ -38,10 +36,7 @@ getHomeR = track "Handler.Snapshots.getAllSnapshotsR" $ do
|
||||
where uncrapify now' snapshot =
|
||||
( snapshotName snapshot
|
||||
, snapshotTitle snapshot
|
||||
, format (diff True)
|
||||
$ diffUTCTime
|
||||
(UTCTime (snapshotCreated snapshot) 0)
|
||||
now'
|
||||
, dateDiff now' (snapshotCreated snapshot)
|
||||
)
|
||||
groupUp now' = groupBy (on (==) (\(_,_,uploaded) -> uploaded))
|
||||
. map (uncrapify now')
|
||||
|
||||
@ -3,8 +3,6 @@
|
||||
module Handler.Snapshots where
|
||||
|
||||
import Data.Time.Clock
|
||||
import Formatting
|
||||
import Formatting.Time
|
||||
import Import
|
||||
import Stackage.Database
|
||||
|
||||
@ -40,10 +38,7 @@ getAllSnapshotsR = track "Handler.Snapshots.getAllSnapshotsR" $ do
|
||||
where uncrapify now' snapshot =
|
||||
( snapshotName snapshot
|
||||
, snapshotTitle snapshot
|
||||
, format (diff True)
|
||||
$ diffUTCTime
|
||||
(UTCTime (snapshotCreated snapshot) 0)
|
||||
now'
|
||||
, dateDiff now' (snapshotCreated snapshot)
|
||||
)
|
||||
groupUp now' = groupBy (on (==) (\(_,_,uploaded) -> uploaded))
|
||||
. map (uncrapify now')
|
||||
|
||||
11
Import.hs
11
Import.hs
@ -13,6 +13,8 @@ import Data.Text.Read (decimal)
|
||||
import Data.Time.Clock (diffUTCTime)
|
||||
import qualified Prometheus as P
|
||||
import Stackage.Database (SnapName)
|
||||
import Formatting (format)
|
||||
import Formatting.Time (diff)
|
||||
|
||||
parseLtsPair :: Text -> Maybe (Int, Int)
|
||||
parseLtsPair t1 = do
|
||||
@ -60,3 +62,12 @@ track name inner = do
|
||||
"stackage_server_fn"
|
||||
"Stackage Server function call (duration in microseconds).")
|
||||
P.defaultQuantiles))
|
||||
|
||||
dateDiff :: UTCTime -- ^ now
|
||||
-> Day -- ^ target
|
||||
-> LText
|
||||
dateDiff (UTCTime now' _) target
|
||||
| now' == target = "today"
|
||||
| otherwise = format (diff True) $ diffUTCTime
|
||||
(UTCTime target 0)
|
||||
(UTCTime now' 0)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user