2014-03-18 22:55:43 +00:00
|
|
|
{- git-annex metadata, standard fields
|
|
|
|
-
|
2015-01-21 16:50:09 +00:00
|
|
|
- Copyright 2014 Joey Hess <id@joeyh.name>
|
2014-03-18 22:55:43 +00:00
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Annex.MetaData.StandardFields (
|
|
|
|
tagMetaField,
|
|
|
|
yearMetaField,
|
|
|
|
monthMetaField,
|
2017-10-25 19:11:12 +00:00
|
|
|
dayMetaField,
|
2018-04-04 17:42:15 +00:00
|
|
|
isDateMetaField,
|
2014-03-18 22:55:43 +00:00
|
|
|
lastChangedField,
|
2014-03-19 23:10:35 +00:00
|
|
|
mkLastChangedField,
|
2014-03-18 22:55:43 +00:00
|
|
|
isLastChangedField
|
|
|
|
) where
|
|
|
|
|
|
|
|
import Types.MetaData
|
|
|
|
|
|
|
|
import Data.List
|
|
|
|
|
|
|
|
tagMetaField :: MetaField
|
|
|
|
tagMetaField = mkMetaFieldUnchecked "tag"
|
|
|
|
|
|
|
|
yearMetaField :: MetaField
|
|
|
|
yearMetaField = mkMetaFieldUnchecked "year"
|
|
|
|
|
|
|
|
monthMetaField :: MetaField
|
|
|
|
monthMetaField = mkMetaFieldUnchecked "month"
|
|
|
|
|
2017-10-25 19:11:12 +00:00
|
|
|
dayMetaField :: MetaField
|
|
|
|
dayMetaField = mkMetaFieldUnchecked "day"
|
|
|
|
|
2018-04-04 17:42:15 +00:00
|
|
|
isDateMetaField :: MetaField -> Bool
|
2018-04-07 03:11:20 +00:00
|
|
|
isDateMetaField f = case f of
|
|
|
|
yearMetaField -> True
|
|
|
|
monthMetaField -> True
|
|
|
|
dayMetaField -> True
|
|
|
|
_ -> False
|
2018-04-04 17:42:15 +00:00
|
|
|
|
2014-03-19 23:10:35 +00:00
|
|
|
lastChangedField :: MetaField
|
|
|
|
lastChangedField = mkMetaFieldUnchecked lastchanged
|
|
|
|
|
|
|
|
mkLastChangedField :: MetaField -> MetaField
|
|
|
|
mkLastChangedField f = mkMetaFieldUnchecked (fromMetaField f ++ lastchangedSuffix)
|
2014-03-18 22:55:43 +00:00
|
|
|
|
|
|
|
isLastChangedField :: MetaField -> Bool
|
2014-03-19 23:10:35 +00:00
|
|
|
isLastChangedField f
|
|
|
|
| f == lastChangedField = True
|
|
|
|
| otherwise = lastchanged `isSuffixOf` s && s /= lastchangedSuffix
|
2014-03-18 22:55:43 +00:00
|
|
|
where
|
|
|
|
s = fromMetaField f
|
|
|
|
|
|
|
|
lastchanged :: String
|
2014-03-19 23:10:35 +00:00
|
|
|
lastchanged = "lastchanged"
|
|
|
|
|
|
|
|
lastchangedSuffix :: String
|
|
|
|
lastchangedSuffix = "-lastchanged"
|