kopia lustrzana https://gitlab.com/tomaszg/geostat
Another overkill, store datas in Cache class also as std::time_t (timestamp), makes it simpler afterwards without the need to convert back and forth
rodzic
d1fa8363d5
commit
f28ca37ee1
|
@ -33,7 +33,7 @@ void Cache::set_date(const std::tm& t) {
|
|||
char tmp[20];
|
||||
|
||||
date_tm = t;
|
||||
std::mktime(&date_tm);
|
||||
date_t = std::mktime(&date_tm);
|
||||
|
||||
year = std::to_string(1900 + date_tm.tm_year);
|
||||
std::strftime(tmp, 20, "(%m) %B", &date_tm);
|
||||
|
@ -45,14 +45,13 @@ void Cache::set_date(const std::tm& t) {
|
|||
|
||||
std::strftime(tmp, 20, "%F", &date_tm);
|
||||
date = tmp;
|
||||
//date += std::to_string(date_tm.tm_hour) + ":" + std::to_string(date_tm.tm_min) + ":" + std::to_string(date_tm.tm_sec);
|
||||
}
|
||||
|
||||
void Cache::set_date_hidden(const std::tm& t) {
|
||||
char tmp[20];
|
||||
|
||||
date_hidden_tm = t;
|
||||
std::mktime(&date_hidden_tm);
|
||||
date_hidden_t = std::mktime(&date_hidden_tm);
|
||||
|
||||
std::strftime(tmp, 20, "%F", &date_hidden_tm);
|
||||
date_hidden = tmp;
|
||||
|
|
2
cache.h
2
cache.h
|
@ -58,6 +58,8 @@ public:
|
|||
std::string origin;
|
||||
std::string owner;
|
||||
std::string owner_uuid;
|
||||
std::time_t date_t;
|
||||
std::time_t date_hidden_t;
|
||||
std::tm date_tm;
|
||||
std::tm date_hidden_tm;
|
||||
std::string year;
|
||||
|
|
|
@ -231,18 +231,15 @@ int main(int argc, char** argv) {
|
|||
Sorted_Caches caches_by_finds;
|
||||
Caches fcc;
|
||||
|
||||
std::tm tmp;
|
||||
if (!get_not_found) {
|
||||
for (auto& i : cc) {
|
||||
dates[i.date]++;
|
||||
tmp = i.date_tm;
|
||||
sorted_caches.insert({ std::mktime(&tmp), &i });
|
||||
sorted_caches.insert({ i.date_t, &i });
|
||||
if (i.type != "Moving" && i.type != "Own" && (!get_not_found || !exclude_quiz || i.type != "Quiz")) {
|
||||
sorted_fcaches.insert({ std::mktime(&tmp), &i });
|
||||
sorted_fcaches.insert({ i.date_t, &i });
|
||||
fcc.insert(i);
|
||||
}
|
||||
tmp = i.date_hidden_tm;
|
||||
sorted_caches_by_hidden.insert({ std::mktime(&tmp), &i });
|
||||
sorted_caches_by_hidden.insert({ i.date_hidden_t, &i });
|
||||
caches_by_fav.push_back(&i);
|
||||
caches_by_fav_perc.push_back(&i);
|
||||
caches_by_finds.push_back(&i);
|
||||
|
|
|
@ -243,13 +243,11 @@ int main(int argc, char** argv) {
|
|||
Date_Caches sorted_caches;
|
||||
Caches fcc;
|
||||
|
||||
std::tm tmp;
|
||||
if (!get_not_found) {
|
||||
for (auto& i : cc) {
|
||||
dates[i.date]++;
|
||||
if (i.type != "Moving" && i.type != "Own") {
|
||||
tmp = i.date_tm;
|
||||
sorted_caches.insert({ std::mktime(&tmp), &i });
|
||||
sorted_caches.insert({ i.date_t, &i });
|
||||
fcc.insert(i);
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue