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
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2014-03-18 22:55:43 +00:00
|
|
|
-}
|
|
|
|
|
2019-01-07 19:51:05 +00:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
2014-03-18 22:55:43 +00:00
|
|
|
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
|
|
|
|
|
2019-01-07 19:51:05 +00:00
|
|
|
import qualified Data.Text as T
|
2019-01-18 18:09:35 +00:00
|
|
|
import Data.Monoid
|
|
|
|
import Prelude
|
2014-03-18 22:55:43 +00:00
|
|
|
|
|
|
|
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-09 17:10:44 +00:00
|
|
|
isDateMetaField f
|
|
|
|
| f == yearMetaField = True
|
|
|
|
| f == monthMetaField = True
|
|
|
|
| f == dayMetaField = True
|
|
|
|
| otherwise = 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
|
2019-01-07 19:51:05 +00:00
|
|
|
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
|
2019-01-07 19:51:05 +00:00
|
|
|
| otherwise = lastchanged `T.isSuffixOf` s && s /= lastchangedSuffix
|
2014-03-18 22:55:43 +00:00
|
|
|
where
|
|
|
|
s = fromMetaField f
|
|
|
|
|
2019-01-07 19:51:05 +00:00
|
|
|
lastchanged :: T.Text
|
2014-03-19 23:10:35 +00:00
|
|
|
lastchanged = "lastchanged"
|
|
|
|
|
2019-01-07 19:51:05 +00:00
|
|
|
lastchangedSuffix :: T.Text
|
2014-03-19 23:10:35 +00:00
|
|
|
lastchangedSuffix = "-lastchanged"
|