From 7aa45dc1cb2eb8aabd31fb9399d6036264bc6f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Goli=C5=84ski?= Date: Thu, 7 Nov 2019 17:25:17 +0100 Subject: [PATCH] Since C++ doesn't allow nesting pointers to members of a class, the simplest way to get a histogram for date components was to duplicate some of them as plain members At the same time it was possible to convert month number to name. --- cache.h | 4 ++++ okapi.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/cache.h b/cache.h index c869e3a..04e36e6 100644 --- a/cache.h +++ b/cache.h @@ -52,6 +52,10 @@ public: std::string owner; std::string owner_uuid; std::tm date_found; + std::string year; + std::string mon; + std::string day; + std::string hour; static Position home; diff --git a/okapi.cpp b/okapi.cpp index c08c1cc..9624230 100644 --- a/okapi.cpp +++ b/okapi.cpp @@ -105,6 +105,7 @@ std::string Okapi::get_caches_json(std::string codes) { Caches Okapi::get_caches(std::vector> codes) { Cache c; Caches cc; + char month[20]; uint n = 0; while (n < codes.size()) { @@ -135,6 +136,11 @@ Caches Okapi::get_caches(std::vector> codes) { for (auto& el2 : codes) { if (el2.first == c.code) { c.date_found = el2.second; + c.year = std::to_string(el2.second.tm_year); + std::strftime(month, 20, "%B", &el2.second); + c.mon = month; + c.day = std::to_string(el2.second.tm_mday); + c.hour = std::to_string(el2.second.tm_hour); break; } }