From d687dc127ecdfa645369b3d98721446f987ce01d Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 17 Apr 2019 03:04:27 +0200 Subject: [PATCH] Added pubDate for each item. --- CMakeLists.txt | 2 +- src/main.cpp | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 416388f..b3a7f7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.2) project(gitea2rss - VERSION 0.0.0 + VERSION 0.1.0 LANGUAGES CXX ) diff --git a/src/main.cpp b/src/main.cpp index 1e92f82..ca0987f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,8 @@ #include #include #include +#include +#include #include #include #include @@ -75,7 +77,7 @@ const string get_http(const string &url) return answer; } -// RFC 822 compliant time string. +// Convert time_point to RFC 822 compliant time string. const string strtime(const system_clock::time_point &timepoint) { constexpr uint16_t bufsize = 1024; @@ -87,6 +89,15 @@ const string strtime(const system_clock::time_point &timepoint) return static_cast(buffer); } +// Convert ISO 8601 time string to RFC 822 time string. +const string strtime(const string &time) +{ + std::tm tm = {}; + std::stringstream ss(time); + ss >> std::get_time(&tm, "%Y-%m-%dT%T%z"); + return strtime(std::chrono::system_clock::from_time_t(std::mktime(&tm))); +} + int main(int argc, char *argv[]) { if (argc < 2) @@ -131,8 +142,11 @@ int main(int argc, char *argv[]) << release["id"].asString() << "\n" " " << domain << " release " << release["id"].asString() << "\n" - " " << type << "\n\n" - << release["body"].asString() << "\n"; + " " + << strtime(release["published_at"].asString()) << "" + " " << type << "

" + << "
" << release["body"].asString()
+             << "
]]
\n"; // for (const Json::Value &file : release["assets"]) // {