Skip to content

Commit

Permalink
Add pub_date field on Item
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Apr 25, 2015
1 parent 24d1e7d commit c695fa0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ pub struct Item {
pub comments: Option<String>,
// pub enclosure
// pub guid
// pub pubDate
pub pub_date: Option<String>, // add a custom String type to parse this date?
// pub source
}

Expand All @@ -349,6 +349,7 @@ impl ViaXml for Item {
item.tag_with_optional_text("description", &self.description);
item.tag_with_optional_text("author", &self.author);
item.tag_with_optional_text("comments", &self.comments);
item.tag_with_optional_text("pubDate", &self.pub_date);

for category in &self.categories {
item.tag(category.to_xml());
Expand All @@ -363,6 +364,7 @@ impl ViaXml for Item {
let description = element.get_child("description", None).map(Element::content_str);
let author = element.get_child("author", None).map(Element::content_str);
let comments = element.get_child("comments", None).map(Element::content_str);
let pub_date = element.get_child("pubDate", None).map(Element::content_str);

let categories = element.get_children("category", None)
.map(|e| ViaXml::from_xml(e.clone()).unwrap())
Expand All @@ -375,6 +377,7 @@ impl ViaXml for Item {
categories: categories,
author: author,
comments: comments,
pub_date: pub_date,
})
}
}
Expand Down

0 comments on commit c695fa0

Please sign in to comment.