@@ -14,6 +14,7 @@ module Hakyll.Web.Template.Context
1414 , titleField
1515 , dateField
1616 , dateFieldWith
17+ , getItemUTC
1718 , modificationTimeField
1819 , modificationTimeFieldWith
1920 , missingField
@@ -158,26 +159,29 @@ dateFieldWith :: TimeLocale -- ^ Output time locale
158159 -> String -- ^ Format to use on the date
159160 -> Context a -- ^ Resulting context
160161dateFieldWith locale key format = field key $ \i -> do
161− time <- getUTC locale $ itemIdentifier i
162+ time <- getItemUTC locale $ itemIdentifier i
162163 return $ formatTime locale format time
163164
164165
165166--------------------------------------------------------------------------------
166167-- | Parser to try to extract and parse the time from the @published@
167168-- field or from the filename. See 'renderDateField' for more information.
168−getUTC :: TimeLocale -- ^ Output time locale
169− -> Identifier -- ^ Input page
170− -> Compiler UTCTime -- ^ Parsed UTCTime
171−getUTC locale id' = do
169+-- Exported for user convenience.
170+getItemUTC :: TimeLocale -- ^ Output time locale
171+ -> Identifier -- ^ Input page
172+ -> Compiler UTCTime -- ^ Parsed UTCTime
173+getItemUTC locale id' = do
172174 metadata <- getMetadata id'
173175 let tryField k fmt = M.lookup k metadata >>= parseTime' fmt
174176 fn = takeFileName $ toFilePath id'
175177
176− maybe empty return $ msum $
178+ maybe empty' return $ msum $
177179 [tryField "published" fmt | fmt <- formats] ++
178180 [tryField "date" fmt | fmt <- formats] ++
179181 [parseTime' "%Y-%m-%d" $ intercalate "-" $ take 3 $ splitAll "-" fn]
180182 where
183+ empty' = compilerThrow $ "Hakyll.Web.Template.Context.getItemUTC: " ++
184+ "could not parse time for " ++ show id'
181185 parseTime' = parseTime locale
182186 formats =
183187 [ "%a, %d %b %Y %H:%M:%S UT"