diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2011-09-16 20:42:31 +0200 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2011-09-16 20:42:31 +0200 |
commit | 6808c5350e4eafacf115eb24078c61cf59caa4b2 (patch) | |
tree | 90e9eb09954fc1e11ba07102f255f0a531963db9 /src/Hakyll/Core/Resource/Provider | |
parent | 5517a140e36ae6f78eca24a7e0984b0bbd7a1283 (diff) | |
download | hakyll-6808c5350e4eafacf115eb24078c61cf59caa4b2.tar.gz |
Add modification time access for resources
Diffstat (limited to 'src/Hakyll/Core/Resource/Provider')
-rw-r--r-- | src/Hakyll/Core/Resource/Provider/Dummy.hs | 4 | ||||
-rw-r--r-- | src/Hakyll/Core/Resource/Provider/File.hs | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/Hakyll/Core/Resource/Provider/Dummy.hs b/src/Hakyll/Core/Resource/Provider/Dummy.hs index 9f15178..dad7b0b 100644 --- a/src/Hakyll/Core/Resource/Provider/Dummy.hs +++ b/src/Hakyll/Core/Resource/Provider/Dummy.hs @@ -7,9 +7,10 @@ module Hakyll.Core.Resource.Provider.Dummy import Data.Map (Map) import qualified Data.Map as M +import Data.Time (getCurrentTime) +import Data.ByteString.Lazy (ByteString) import qualified Data.Text.Lazy as TL import qualified Data.Text.Lazy.Encoding as TL -import Data.ByteString.Lazy (ByteString) import Hakyll.Core.Resource import Hakyll.Core.Resource.Provider @@ -21,3 +22,4 @@ dummyResourceProvider vfs = makeResourceProvider (map Resource (M.keys vfs)) (return . TL.unpack . TL.decodeUtf8 . (vfs M.!) . unResource) (return . (vfs M.!) . unResource) + (const getCurrentTime) diff --git a/src/Hakyll/Core/Resource/Provider/File.hs b/src/Hakyll/Core/Resource/Provider/File.hs index c0e306a..abb7ebe 100644 --- a/src/Hakyll/Core/Resource/Provider/File.hs +++ b/src/Hakyll/Core/Resource/Provider/File.hs @@ -6,6 +6,10 @@ module Hakyll.Core.Resource.Provider.File import Control.Applicative ((<$>)) +import Data.Time (readTime) +import System.Directory (getModificationTime) +import System.Locale (defaultTimeLocale) +import System.Time (formatCalendarTime, toCalendarTime) import qualified Data.ByteString.Lazy as LB import Hakyll.Core.Resource @@ -22,3 +26,9 @@ fileResourceProvider configuration = do getRecursiveContents False "." makeResourceProvider list (readFile . unResource) (LB.readFile . unResource) + mtime + where + mtime (Resource r) = do + ct <- toCalendarTime =<< getModificationTime r + let str = formatCalendarTime defaultTimeLocale "%s" ct + return $ readTime defaultTimeLocale "%s" str |