diff --git a/src/Rss/RssElementNames.cs b/src/Rss/RssElementNames.cs
index ef04a10..25a748a 100644
--- a/src/Rss/RssElementNames.cs
+++ b/src/Rss/RssElementNames.cs
@@ -36,6 +36,7 @@ public static class RssElementNames
public const string TextInput = "textInput";
public const string TimeToLive = "ttl";
public const string Title = "title";
+ public const string Updated = "updated";
public const string Url = "url";
public const string Version = "version";
}
diff --git a/src/Rss/RssFormatter.cs b/src/Rss/RssFormatter.cs
index cb3d7c0..fd55aab 100644
--- a/src/Rss/RssFormatter.cs
+++ b/src/Rss/RssFormatter.cs
@@ -308,6 +308,13 @@ public virtual ISyndicationContent CreateContent(ISyndicationItem item)
content.AddField(new SyndicationContent(RssElementNames.PubDate, FormatValue(item.Published)));
}
+ //
+ // Updated
+ if (item.LastUpdated != DateTimeOffset.MinValue)
+ {
+ content.AddField(new SyndicationContent(RssElementNames.Updated, Atom.AtomConstants.Atom10Namespace, FormatValue(item.LastUpdated)));
+ }
+
return content;
}
diff --git a/src/Rss/RssParser.cs b/src/Rss/RssParser.cs
index 4f9b0b7..c3af3aa 100644
--- a/src/Rss/RssParser.cs
+++ b/src/Rss/RssParser.cs
@@ -107,7 +107,16 @@ public virtual ISyndicationItem CreateItem(ISyndicationContent content)
var item = new SyndicationItem();
foreach (var field in content.Fields)
- {
+ {
+ //
+ // Updated
+ if (field.Namespace == Atom.AtomConstants.Atom10Namespace
+ && field.Name == RssElementNames.Updated
+ && TryParseValue(field.Value, out DateTimeOffset updated))
+ {
+ item.LastUpdated = updated;
+ }
+
if (field.Namespace != RssConstants.Rss20Namespace)
{
continue;
diff --git a/tests/RssReader.cs b/tests/RssReader.cs
index 6882d73..afd755d 100644
--- a/tests/RssReader.cs
+++ b/tests/RssReader.cs
@@ -65,6 +65,9 @@ public async Task ReadItemAsContent()
Assert.Equal("pubDate", fields[5].Name);
Assert.False(string.IsNullOrEmpty(fields[5].Value));
+
+ Assert.Equal("updated", fields[6].Name);
+ Assert.False(string.IsNullOrEmpty(fields[6].Value));
}
}
}
@@ -211,12 +214,14 @@ public static async Task TestReadFeedElements(XmlReader outerXmlReader)
Assert.True(item.Title == "Lorem ipsum 2017-07-06T20:25:00+00:00");
Assert.True(item.Description == "Exercitation sit dolore mollit et est eiusmod veniam aute officia veniam ipsum.");
Assert.True(item.Links.Count() == 3);
+ Assert.True(item.LastUpdated.ToString() == "12/6/2017 8:25:00 PM +00:00");
}
else if(items == 2)
{
Assert.True(item.Title == "Lorem ipsum 2017-07-06T20:24:00+00:00");
Assert.True(item.Description == "Do ipsum dolore veniam minim est cillum aliqua ea.");
Assert.True(item.Links.Count() == 3);
+ Assert.True(item.LastUpdated.ToString() == "12/6/2017 8:25:00 PM +00:00");
}
break;
diff --git a/tests/RssWriter.cs b/tests/RssWriter.cs
index 617e987..6c0480c 100644
--- a/tests/RssWriter.cs
+++ b/tests/RssWriter.cs
@@ -264,8 +264,9 @@ public async Task Echo()
var sw = new StringWriterWithEncoding(Encoding.UTF8);
using (var xmlWriter = XmlWriter.Create(sw))
- {
- var writer = new RssFeedWriter(xmlWriter);
+ {
+ var attributes = new SyndicationAttribute[] { new SyndicationAttribute("xmlns:a10", "http://www.w3.org/2005/Atom") };
+ var writer = new RssFeedWriter(xmlWriter, attributes);
while (await reader.Read())
{
@@ -293,7 +294,7 @@ public async Task Echo()
}
res = sw.ToString();
- Assert.True(res == "Lorem ipsum feed for an interval of 1 minutesThis is a constantly updating lorem ipsum feedhttp://example.com/http://2.bp.blogspot.com/-NA5Jb-64eUg/URx8CSdcj_I/AAAAAAAAAUo/eCx0irI0rq0/s1600/bg_Microsoft_logo3-20120824073001907469-620x349.jpgMicrosoft Newshttp://www.microsoft.com/newsTest descriptionRSS for NodeThu, 06 Jul 2017 20:25:17 GMTJohn SmithThu, 06 Jul 2017 20:25:00 GMTMichael Bertolacci, licensed under a Creative Commons Attribution 3.0 Unported License.60- Lorem ipsum 2017-07-06T20:25:00+00:00http://example.com/test/1499372700http://example.com/test/1499372700Exercitation sit dolore mollit et est eiusmod veniam aute officia veniam ipsum.John SmithThu, 06 Jul 2017 20:25:00 GMT
- Lorem ipsum 2017-07-06T20:24:00+00:00http://example.com/test/1499372640http://example.com/test/1499372640Do ipsum dolore veniam minim est cillum aliqua ea.John SmithThu, 06 Jul 2017 20:24:00 GMT
");
+ Assert.True(res == "Lorem ipsum feed for an interval of 1 minutesThis is a constantly updating lorem ipsum feedhttp://example.com/http://2.bp.blogspot.com/-NA5Jb-64eUg/URx8CSdcj_I/AAAAAAAAAUo/eCx0irI0rq0/s1600/bg_Microsoft_logo3-20120824073001907469-620x349.jpgMicrosoft Newshttp://www.microsoft.com/newsTest descriptionRSS for NodeThu, 06 Jul 2017 20:25:17 GMTJohn SmithThu, 06 Jul 2017 20:25:00 GMTMichael Bertolacci, licensed under a Creative Commons Attribution 3.0 Unported License.60- Lorem ipsum 2017-07-06T20:25:00+00:00http://example.com/test/1499372700http://example.com/test/1499372700Exercitation sit dolore mollit et est eiusmod veniam aute officia veniam ipsum.John SmithThu, 06 Jul 2017 20:25:00 GMTWed, 06 Dec 2017 20:25:00 GMT
- Lorem ipsum 2017-07-06T20:24:00+00:00http://example.com/test/1499372640http://example.com/test/1499372640Do ipsum dolore veniam minim est cillum aliqua ea.John SmithThu, 06 Jul 2017 20:24:00 GMTWed, 06 Dec 2017 20:25:00 GMT
");
}
await RssReader.TestReadFeedElements(XmlReader.Create(new StringReader(res)));
diff --git a/tests/TestFeeds/rss20-2items.xml b/tests/TestFeeds/rss20-2items.xml
index 7ef4f4d..cf77431 100644
--- a/tests/TestFeeds/rss20-2items.xml
+++ b/tests/TestFeeds/rss20-2items.xml
@@ -1,5 +1,5 @@
-
+
@@ -24,6 +24,7 @@
http://example.com/test/1499372700
Thu, 06 Jul 2017 20:25:00 GMT
+ Thu, 06 Dec 2017 20:25:00 GMT
Testing Custom Elements
-
@@ -33,6 +34,7 @@
http://example.com/test/1499372640
Thu, 06 Jul 2017 20:24:00 GMT
+ Thu, 06 Dec 2017 20:25:00 GMT
Ignored Text
Testing Custom Elements
diff --git a/tests/TestFeeds/rss20.xml b/tests/TestFeeds/rss20.xml
index e273322..8a593a9 100644
--- a/tests/TestFeeds/rss20.xml
+++ b/tests/TestFeeds/rss20.xml
@@ -1,5 +1,5 @@
-
+
abc@def.com (John Doe)
@@ -25,6 +25,7 @@
http://example.com/test/1499372700
Thu, 06 Jul 2017 20:25:00 GMT
+ Thu, 06 Dec 2017 20:25:00 GMT
Newspapers
-
@@ -34,6 +35,7 @@
http://example.com/test/1499372640
Thu, 06 Jul 2017 20:24:00 GMT
+ Thu, 06 Dec 2017 20:25:00 GMT
Newspapers
-
@@ -43,6 +45,7 @@
http://example.com/test/1499372580
Thu, 06 Jul 2017 20:23:00 GMT
+ Thu, 06 Dec 2017 20:25:00 GMT
-
@@ -51,6 +54,7 @@
http://example.com/test/1499372520
Thu, 06 Jul 2017 20:22:00 GMT
+ Thu, 06 Dec 2017 20:25:00 GMT
-
@@ -59,6 +63,7 @@
http://example.com/test/1499372460
Thu, 06 Jul 2017 20:21:00 GMT
+ Thu, 06 Dec 2017 20:25:00 GMT
-
@@ -67,6 +72,7 @@
http://example.com/test/1499372400
Thu, 06 Jul 2017 20:20:00 GMT
+ Thu, 06 Dec 2017 20:25:00 GMT
-
@@ -75,6 +81,7 @@
http://example.com/test/1499372340
Thu, 06 Jul 2017 20:19:00 GMT
+ Thu, 06 Dec 2017 20:25:00 GMT
-
@@ -83,6 +90,7 @@
http://example.com/test/1499372280
Thu, 06 Jul 2017 20:18:00 GMT
+ Thu, 06 Dec 2017 20:25:00 GMT
-
@@ -91,6 +99,7 @@
http://example.com/test/1499372220
Thu, 06 Jul 2017 20:17:00 GMT
+ Thu, 06 Dec 2017 20:25:00 GMT
-
@@ -99,6 +108,7 @@
http://example.com/test/1499372160
Thu, 06 Jul 2017 20:16:00 GMT
+ Thu, 06 Dec 2017 20:25:00 GMT
\ No newline at end of file