summaryrefslogtreecommitdiff
path: root/src/statistics/ScheduledPage.cpp
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2021-07-14 11:49:10 +1200
commitd24f813f3f2a05c112e803e4256b53535895fc98 (patch)
tree601e6ae9a1cd44bcfdcf91739a5ca36aedd827c9 /src/statistics/ScheduledPage.cpp
Initial mirror commitHEADmaster
Diffstat (limited to 'src/statistics/ScheduledPage.cpp')
-rw-r--r--src/statistics/ScheduledPage.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/statistics/ScheduledPage.cpp b/src/statistics/ScheduledPage.cpp
new file mode 100644
index 0000000..5e2b558
--- /dev/null
+++ b/src/statistics/ScheduledPage.cpp
@@ -0,0 +1,35 @@
+#include "ScheduledPage.h"
+#include "../dictionary/CardPack.h"
+
+ScheduledPage::ScheduledPage(const StatisticsParams* statParams):
+ TimeChartPage(statParams)
+{
+ init();
+}
+
+QList<QDateTime> ScheduledPage::getDates(const CardPack* pack) const
+{
+ QList<QDateTime> scheduled = pack->getScheduledDates();
+ adjustScheduledRecords(scheduled);
+ return scheduled;
+}
+
+void ScheduledPage::adjustScheduledRecords(QList<QDateTime>& scheduled)
+{
+ const QDate curDate = QDate::currentDate();
+ const QTime zeroTime = QTime(0, 0);
+ for(int i = 0; i < scheduled.size(); i++)
+ {
+ QDateTime& dateTime = scheduled[i];
+ if(dateTime.date() < curDate)
+ dateTime = QDateTime(curDate, zeroTime);
+ else if(laterThisDay(dateTime))
+ dateTime = QDateTime(curDate.addDays(1), zeroTime);
+ }
+}
+
+bool ScheduledPage::laterThisDay(QDateTime& dateTime)
+{
+ return dateTime.date() == QDate::currentDate() &&
+ dateTime > QDateTime::currentDateTime();
+}