aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/datetime/planner-eds.h4
-rw-r--r--src/main.cpp2
-rw-r--r--src/planner-eds.cpp16
-rw-r--r--tests/test-planner.cpp4
4 files changed, 17 insertions, 9 deletions
diff --git a/include/datetime/planner-eds.h b/include/datetime/planner-eds.h
index a99f611..32ea57a 100644
--- a/include/datetime/planner-eds.h
+++ b/include/datetime/planner-eds.h
@@ -22,6 +22,7 @@
#include <datetime/clock.h>
#include <datetime/planner.h>
+#include <datetime/timezones.h>
#include <memory> // shared_ptr, unique_ptr
@@ -35,7 +36,8 @@ namespace datetime {
class PlannerEds: public Planner
{
public:
- PlannerEds(const std::shared_ptr<Clock>& clock);
+ PlannerEds(const std::shared_ptr<Clock>& clock,
+ const std::shared_ptr<Timezones>& timezones);
virtual ~PlannerEds();
private:
diff --git a/src/main.cpp b/src/main.cpp
index 31d9db6..762795f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -59,7 +59,7 @@ main(int /*argc*/, char** /*argv*/)
state->settings = live_settings;
state->clock = live_clock;
state->locations.reset(new SettingsLocations(live_settings, live_timezones));
- state->planner.reset(new PlannerEds(live_clock));
+ state->planner.reset(new PlannerEds(live_clock, live_timezones));
state->planner->time = live_clock->localtime();
std::shared_ptr<Actions> actions(new LiveActions(state));
MenuFactory factory(actions, state);
diff --git a/src/planner-eds.cpp b/src/planner-eds.cpp
index da406eb..8bf4665 100644
--- a/src/planner-eds.cpp
+++ b/src/planner-eds.cpp
@@ -41,9 +41,12 @@ class PlannerEds::Impl
{
public:
- Impl(PlannerEds& owner, const std::shared_ptr<Clock>& clock):
+ Impl(PlannerEds& owner,
+ const std::shared_ptr<Clock>& clock,
+ const std::shared_ptr<Timezones>& timezones):
m_owner(owner),
m_clock(clock),
+ m_timezones(timezones),
m_cancellable(g_cancellable_new())
{
e_source_registry_new(m_cancellable, on_source_registry_ready, this);
@@ -362,7 +365,7 @@ private:
void rebuild_upcoming()
{
const auto ref = m_clock->localtime();
- const auto begin = g_date_time_add_minutes(ref.get(),-10);
+ const auto begin = g_date_time_add_days(ref.get(),-1);
const auto end = g_date_time_add_months(begin,1);
get_appointments(begin, end, [this](const std::vector<Appointment>& appointments) {
@@ -390,9 +393,7 @@ private:
**/
icaltimezone * default_timezone = nullptr;
-
- const auto tz = g_date_time_get_timezone_abbreviation(m_owner.time.get().get());
- g_debug("%s tz is %s", G_STRLOC, tz);
+ const auto tz = m_timezones->timezone.get().c_str();
if (tz && *tz)
{
default_timezone = icaltimezone_get_builtin_timezone(tz);
@@ -535,6 +536,7 @@ private:
PlannerEds& m_owner;
std::shared_ptr<Clock> m_clock;
+ std::shared_ptr<Timezones> m_timezones;
std::set<ESource*> m_sources;
std::map<ESource*,ECalClient*> m_clients;
std::map<ESource*,ECalClientView*> m_views;
@@ -545,7 +547,9 @@ private:
enum { UPCOMING=(1<<0), MONTH=(1<<1), ALL=UPCOMING|MONTH };
};
-PlannerEds::PlannerEds(const std::shared_ptr<Clock>& clock): p(new Impl(*this, clock)) {}
+PlannerEds::PlannerEds(const std::shared_ptr<Clock>& clock,
+ const std::shared_ptr<Timezones>& timezones):
+ p(new Impl(*this, clock, timezones)) {}
PlannerEds::~PlannerEds() =default;
diff --git a/tests/test-planner.cpp b/tests/test-planner.cpp
index 1923ba1..e5c11f9 100644
--- a/tests/test-planner.cpp
+++ b/tests/test-planner.cpp
@@ -24,6 +24,7 @@
#include <datetime/date-time.h>
#include <datetime/planner.h>
#include <datetime/planner-eds.h>
+#include <datetime/timezones.h>
#include <langinfo.h>
#include <locale.h>
@@ -43,7 +44,8 @@ TEST_F(PlannerFixture, EDS)
g_date_time_unref(tmp);
std::shared_ptr<Clock> clock(new MockClock(now));
- PlannerEds planner(clock);
+ std::shared_ptr<Timezones> timezones(new Timezones);
+ PlannerEds planner(clock, timezones);
wait_msec(100);
planner.time.set(now);