Mercurial > minori
diff src/gui/pages/statistics.cc @ 258:862d0d8619f6
*: HUUUGE changes
animia has been renamed to animone, so instead of thinking of a
health condition, you think of a beautiful flower :)
I've also edited some of the code for animone, but I have no idea
if it even works or not because I don't have a mac or windows
machine lying around. whoops!
... anyway, all of the changes divergent from Anisthesia are now
licensed under BSD. it's possible that I could even rewrite most
of the code to where I don't even have to keep the MIT license,
but that's thinking too far into the future
I've been slacking off on implementing the anime seasons page,
mostly out of laziness. I think I'd have to create another db file
specifically for the seasons
anyway, this code is being pushed *primarily* because the hard drive
it's on is failing! yay :)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 01 Apr 2024 02:43:44 -0400 |
parents | d14f8e0e40c3 |
children | 9a88e1725fd2 |
line wrap: on
line diff
--- a/src/gui/pages/statistics.cc Sun Feb 18 16:02:14 2024 -0500 +++ b/src/gui/pages/statistics.cc Mon Apr 01 02:43:44 2024 -0400 @@ -1,10 +1,10 @@ #include "gui/pages/statistics.h" #include "core/anime_db.h" +#include "core/session.h" #include "core/strings.h" -#include "core/session.h" #include "gui/pages/anime_list.h" +#include "gui/widgets/graph.h" #include "gui/widgets/text.h" -#include "gui/widgets/graph.h" #include <QString> #include <QTextDocument> @@ -13,8 +13,8 @@ #include <QVBoxLayout> #include <QWidget> +#include <cmath> #include <sstream> -#include <cmath> enum class TimeUnits { SECONDS, @@ -60,7 +60,6 @@ layout->addWidget(score_dist_widget); } - _application.reset(new TextWidgets::LabelledSection(tr("Minori"), tr("Uptime:\nRequests made:"), "\n\n", this)); layout->addWidget(_application.get()); @@ -84,7 +83,7 @@ * amount of units to parse * [in, defaults to 1.0] double unit_in_seconds: * equivalent of one of 'amount' in seconds, e.g. minutes would be 60.0 -*/ + */ static std::string TimeToDateString(TimeUnits unit, int amount, double unit_in_seconds = 1.0) { /* avoid calculating this twice */ const double years_conv = (31556952.0 / unit_in_seconds); @@ -94,14 +93,15 @@ const double minutes_conv = (60.0 / unit_in_seconds); const double seconds_conv = (1.0 / unit_in_seconds); - const int years = amount / years_conv; - const int months = std::fmod(amount, years_conv) / months_conv; - const int days = std::fmod(amount, months_conv) / days_conv; - const int hours = std::fmod(amount, days_conv) / hours_conv; - const int minutes = std::fmod(amount, hours_conv) / minutes_conv; + const int years = amount / years_conv; + const int months = std::fmod(amount, years_conv) / months_conv; + const int days = std::fmod(amount, months_conv) / days_conv; + const int hours = std::fmod(amount, days_conv) / hours_conv; + const int minutes = std::fmod(amount, hours_conv) / minutes_conv; const int seconds = std::fmod(amount, minutes_conv) / seconds_conv; - const auto add_time_segment = [](std::ostringstream& str, int amount, const std::string_view& singular, const std::string_view& plural, bool always = false) { + const auto add_time_segment = [](std::ostringstream& str, int amount, const std::string_view& singular, + const std::string_view& plural, bool always = false) { if (amount > 0 || always) str << amount << ((amount == 1) ? singular : plural); };