aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Atom.hs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/Atom.hs b/src/Atom.hs
index d5dcdad..3f2f652 100644
--- a/src/Atom.hs
+++ b/src/Atom.hs
@@ -36,10 +36,25 @@ parseUpdated :: MonadLogger m => Cursor -> m (Maybe UTCTime)
parseUpdated c = parseW3Rfc822 $ mconcat $ parseFieldContent "updated" c
parseEntryUpdated :: MonadLogger m => Cursor -> m (Maybe UTCTime)
-parseEntryUpdated c = case parseFieldContent "updated" c of
+parseEntryUpdated c = do
+ mu <- parseEntrySourceUpdated c
+ case mu of
+ Nothing -> parseEntryUpdated' c
+ Just u -> return $ Just u
+-- parseEntryUpdated = parseEntryUpdated'
+
+parseEntryUpdated' :: MonadLogger m => Cursor -> m (Maybe UTCTime)
+parseEntryUpdated' c = case parseFieldContent "updated" c of
[] -> parseW3Rfc822 $ mconcat $ parseFieldContent "published" c
us -> parseW3Rfc822 $ mconcat us
+-- | "source > updated" is useful for "planet" feeds, it is often more accurate
+-- than "updated"
+parseEntrySourceUpdated :: MonadLogger m => Cursor -> m (Maybe UTCTime)
+parseEntrySourceUpdated c = case (c $/ localNameFilter "source" &/ localNameFilter "updated" &// content) of
+ [] -> return Nothing
+ us -> parseW3Rfc822 $ mconcat us
+
parseLink :: Cursor -> Link
parseLink c = do
let href = case mconcat $ c $| attribute "href" of