renamed date to gameDate
This commit is contained in:
parent
dc2f632563
commit
9c0ebb42d1
|
@ -157,7 +157,7 @@ verifyDataC = Controller
|
||||||
let gs = s^.progMode.gameStateL
|
let gs = s^.progMode.gameStateL
|
||||||
header s
|
header s
|
||||||
C.drawString "\n"
|
C.drawString "\n"
|
||||||
C.drawString $ " Date: " ++ date gs ++ "\n"
|
C.drawString $ " Date: " ++ gameDate gs ++ "\n"
|
||||||
C.drawString $ " Game type: " ++ show (fromJust $ gs^.gameType) ++ "\n"
|
C.drawString $ " Game type: " ++ show (fromJust $ gs^.gameType) ++ "\n"
|
||||||
C.drawString $ "Other team: " ++ gs^.otherTeam ++ "\n"
|
C.drawString $ "Other team: " ++ gs^.otherTeam ++ "\n"
|
||||||
C.drawString $ "Home score: " ++ show (fromJust $ gs^.homeScore) ++ "\n"
|
C.drawString $ "Home score: " ++ show (fromJust $ gs^.homeScore) ++ "\n"
|
||||||
|
|
|
@ -19,7 +19,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
-}
|
-}
|
||||||
|
|
||||||
module Mtlstats.Report (report, date) where
|
module Mtlstats.Report (report, gameDate) where
|
||||||
|
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
import Lens.Micro ((^.))
|
import Lens.Micro ((^.))
|
||||||
|
@ -40,7 +40,7 @@ report width s = unlines $ fromMaybe [] $ do
|
||||||
db = s^.database
|
db = s^.database
|
||||||
gs = s^.progMode.gameStateL
|
gs = s^.progMode.gameStateL
|
||||||
gNum = db^.dbGames
|
gNum = db^.dbGames
|
||||||
gDate = date gs
|
date = gameDate gs
|
||||||
hTeam = homeTeam gs
|
hTeam = homeTeam gs
|
||||||
aTeam = awayTeam gs
|
aTeam = awayTeam gs
|
||||||
hStats = db^.dbHomeGameStats
|
hStats = db^.dbHomeGameStats
|
||||||
|
@ -54,7 +54,7 @@ report width s = unlines $ fromMaybe [] $ do
|
||||||
(centre width
|
(centre width
|
||||||
$ aTeam ++ " " ++ show aScore ++ " AT "
|
$ aTeam ++ " " ++ show aScore ++ " AT "
|
||||||
++ hTeam ++ " " ++ show hScore)
|
++ hTeam ++ " " ++ show hScore)
|
||||||
, gDate
|
, date
|
||||||
, centre width "STANDINGS"
|
, centre width "STANDINGS"
|
||||||
, ""
|
, ""
|
||||||
, centre width
|
, centre width
|
||||||
|
@ -78,8 +78,8 @@ report width s = unlines $ fromMaybe [] $ do
|
||||||
++ showStats tStats
|
++ showStats tStats
|
||||||
]
|
]
|
||||||
|
|
||||||
date :: GameState -> String
|
gameDate :: GameState -> String
|
||||||
date gs = fromMaybe "" $ do
|
gameDate gs = fromMaybe "" $ do
|
||||||
year <- show <$> gs^.gameYear
|
year <- show <$> gs^.gameYear
|
||||||
month <- month <$> gs^.gameMonth
|
month <- month <$> gs^.gameMonth
|
||||||
day <- padNum 2 <$> gs^.gameDay
|
day <- padNum 2 <$> gs^.gameDay
|
||||||
|
|
|
@ -29,19 +29,19 @@ import Mtlstats.Types
|
||||||
|
|
||||||
spec :: Spec
|
spec :: Spec
|
||||||
spec = describe "Mtlstats.Report"
|
spec = describe "Mtlstats.Report"
|
||||||
dateSpec
|
gameDateSpec
|
||||||
|
|
||||||
dateSpec :: Spec
|
gameDateSpec :: Spec
|
||||||
dateSpec = describe "date" $ do
|
gameDateSpec = describe "gameDate" $ do
|
||||||
|
|
||||||
context "valid date" $
|
context "valid gameDate" $
|
||||||
it "should format the date" $ let
|
it "should format the date" $ let
|
||||||
gs = newGameState
|
gs = newGameState
|
||||||
& gameYear ?~ 1980
|
& gameYear ?~ 1980
|
||||||
& gameMonth ?~ 6
|
& gameMonth ?~ 6
|
||||||
& gameDay ?~ 25
|
& gameDay ?~ 25
|
||||||
in date gs `shouldBe` "JUN 25 1980"
|
in gameDate gs `shouldBe` "JUN 25 1980"
|
||||||
|
|
||||||
context "invalid date" $
|
context "invalid date" $
|
||||||
it "should return an empty string" $
|
it "should return an empty string" $
|
||||||
date newGameState `shouldBe` ""
|
gameDate newGameState `shouldBe` ""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user