add date related fields to Info
This commit is contained in:
parent
e682b9d545
commit
c6590df71c
1 changed files with 7 additions and 1 deletions
|
@ -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 ->
|
||||
|
|
Loading…
Reference in a new issue