From 0bfa763dc6d541ccf21da9456643067b3d96872f Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sat, 24 Oct 2015 11:42:25 +0200 Subject: Export getModificationTime --- src/Hakyll/Web/Template/Context.hs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/Hakyll/Web/Template/Context.hs b/src/Hakyll/Web/Template/Context.hs index 43857ff..6879187 100644 --- a/src/Hakyll/Web/Template/Context.hs +++ b/src/Hakyll/Web/Template/Context.hs @@ -21,6 +21,7 @@ module Hakyll.Web.Template.Context , dateField , dateFieldWith , getItemUTC + , getItemModificationTime , modificationTimeField , modificationTimeFieldWith , teaserField @@ -295,6 +296,17 @@ getItemUTC locale id' = do ] +-------------------------------------------------------------------------------- +-- | Get the time on which the actual file was last modified. This only works if +-- there actually is an underlying file, of couse. +getItemModificationTime + :: Identifier + -> Compiler UTCTime +getItemModificationTime identifier = do + provider <- compilerProvider <$> compilerAsk + return $ resourceModificationTime provider identifier + + -------------------------------------------------------------------------------- modificationTimeField :: String -- ^ Key -> String -- ^ Format @@ -308,8 +320,7 @@ modificationTimeFieldWith :: TimeLocale -- ^ Time output locale -> String -- ^ Format -> Context a -- ^ Resulting context modificationTimeFieldWith locale key fmt = field key $ \i -> do - provider <- compilerProvider <$> compilerAsk - let mtime = resourceModificationTime provider $ itemIdentifier i + mtime <- getItemModificationTime $ itemIdentifier i return $ formatTime locale fmt mtime -- cgit v1.2.3