add date related fields to Info

This commit is contained in:
Rhiannon Morris 2020-07-18 11:26:59 +02:00
parent e682b9d545
commit c6590df71c

View file

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