implemented Mtlstats.Report.date
This commit is contained in:
+10
-6
@@ -19,7 +19,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-}
|
||||
|
||||
module Mtlstats.Report (report) where
|
||||
module Mtlstats.Report (report, date) where
|
||||
|
||||
import Data.Maybe (fromMaybe)
|
||||
import Lens.Micro ((^.))
|
||||
@@ -40,6 +40,7 @@ report width s = unlines $ fromMaybe [] $ do
|
||||
db = s^.database
|
||||
gs = s^.progMode.gameStateL
|
||||
gNum = db^.dbGames
|
||||
gDate = date gs
|
||||
hTeam = homeTeam gs
|
||||
aTeam = awayTeam gs
|
||||
hStats = db^.dbHomeGameStats
|
||||
@@ -47,17 +48,13 @@ report width s = unlines $ fromMaybe [] $ do
|
||||
tStats = addGameStats hStats aStats
|
||||
hScore <- gs^.homeScore
|
||||
aScore <- gs^.awayScore
|
||||
month <- month <$> gs^.gameMonth
|
||||
day <- padNum 2 <$> gs^.gameDay
|
||||
year <- show <$> gs^.gameYear
|
||||
let date = month ++ " " ++ day ++ " " ++ year
|
||||
Just
|
||||
[ overlay
|
||||
("GAME NUMBER " ++ padNum 2 gNum)
|
||||
(centre width
|
||||
$ aTeam ++ " " ++ show aScore ++ " AT "
|
||||
++ hTeam ++ " " ++ show hScore)
|
||||
, date
|
||||
, gDate
|
||||
, centre width "STANDINGS"
|
||||
, ""
|
||||
, centre width
|
||||
@@ -81,6 +78,13 @@ report width s = unlines $ fromMaybe [] $ do
|
||||
++ showStats tStats
|
||||
]
|
||||
|
||||
date :: GameState -> String
|
||||
date gs = fromMaybe "" $ do
|
||||
year <- show <$> gs^.gameYear
|
||||
month <- month <$> gs^.gameMonth
|
||||
day <- padNum 2 <$> gs^.gameDay
|
||||
Just $ month ++ " " ++ day ++ " " ++ year
|
||||
|
||||
showStats :: GameStats -> String
|
||||
showStats gs
|
||||
= right 2 (show $ gmsGames gs)
|
||||
|
||||
Reference in New Issue
Block a user