From c6590df71c625fea08cd6725623aad6e085b8918 Mon Sep 17 00:00:00 2001 From: Rhiannon Morris Date: Sat, 18 Jul 2020 11:26:59 +0200 Subject: [PATCH] add date related fields to Info --- make-pages/Info.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/make-pages/Info.hs b/make-pages/Info.hs index 96b3208..ad615f3 100644 --- a/make-pages/Info.hs +++ b/make-pages/Info.hs @@ -17,7 +17,7 @@ import Data.Maybe (isJust, isNothing) import Data.String (IsString) import Data.Text (Text) import qualified Data.Text as Text -import Data.Time.Calendar (Day (..)) +import Data.Time.Calendar (Day (..), toGregorian) import Data.YAML (FromYAML (..), (.:), (.:?), (.!=)) import qualified Data.YAML as YAML import Text.Read (readMaybe) @@ -76,6 +76,12 @@ instance HasField "thumb" Info (Maybe FilePath) where instance HasField "mine" Info Bool where getField = isNothing . #artist instance HasField "notMine" Info Bool where getField = isJust . #artist +instance HasField "dmy" Info (Integer, Int, Int) where + getField = toGregorian . #date +instance HasField "year" Info Integer where getField = #first . #dmy +instance HasField "month" Info Int where getField = #second . #dmy +instance HasField "day" Info Int where getField = #third . #dmy + instance FromYAML Info where parseYAML = YAML.withMap "info" \m ->