summaryrefslogtreecommitdiff
path: root/src/RSS.cpp
diff options
context:
space:
mode:
authorPhysick <96335032+DegustatorPonos@users.noreply.github.com>2026-05-10 19:55:02 +0500
committerPhysick <96335032+DegustatorPonos@users.noreply.github.com>2026-05-10 19:55:02 +0500
commit92bee957b4face63285933f48f6d6e04ac064ca8 (patch)
tree00f8b7ae6033165d767c1e371d3a8ce880766e86 /src/RSS.cpp
parente695a65df9d5a8ee7d5af705c4789e44fbcc0b60 (diff)
Time sorting
Diffstat (limited to 'src/RSS.cpp')
-rw-r--r--src/RSS.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/RSS.cpp b/src/RSS.cpp
index 1282c83..93c391d 100644
--- a/src/RSS.cpp
+++ b/src/RSS.cpp
@@ -86,6 +86,18 @@ void RSS::print() {
}
}
+void RSS::print_latest(int minutesSpan) {
+ std::time_t now = std::time(nullptr);
+ std::tm* gmt_time = std::gmtime(&now);
+ gmt_time->tm_min -= minutesSpan;
+ auto ticks = std::mktime(gmt_time);
+
+ for (auto entry : Entries) {
+ if (entry.pubDate.tm_year == 0 || std::mktime(&entry.pubDate) < ticks) break;
+ entry.print();
+ }
+}
+
RSS_Entry::RSS_Entry(XML_leaf node) {
Title = node.GetChild("title").GetValue();
URL = node.GetChild("link").GetValue();
@@ -98,9 +110,10 @@ RSS_Entry::RSS_Entry(XML_leaf node) {
void RSS_Entry::print() {
std::cout
- << "==============================\n"
<< Title << '\n'
<< std::put_time(&pubDate, "%Y-%m-%d %H:%M:%S") << '\n'
<< Contents << '\n'
- << URL<< '\n';
+ << URL<< '\n'
+ << "==============================\n";
}
+