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.
sql-rework
Tomasz Goliński 2019-11-07 17:25:17 +01:00
rodzic 83029fbc54
commit 7aa45dc1cb
2 zmienionych plików z 10 dodań i 0 usunięć

Wyświetl plik

@ -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;

Wyświetl plik

@ -105,6 +105,7 @@ std::string Okapi::get_caches_json(std::string codes) {
Caches Okapi::get_caches(std::vector<std::pair<std::string, std::tm>> 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<std::pair<std::string, std::tm>> 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;
}
}