aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actions-live.cpp3
-rw-r--r--src/actions.cpp4
-rw-r--r--src/alarm-queue-simple.cpp2
-rw-r--r--src/menu.cpp4
-rw-r--r--src/planner-month.cpp7
-rw-r--r--src/planner-upcoming.cpp2
6 files changed, 7 insertions, 15 deletions
diff --git a/src/actions-live.cpp b/src/actions-live.cpp
index 7efc2b2..121744a 100644
--- a/src/actions-live.cpp
+++ b/src/actions-live.cpp
@@ -119,8 +119,7 @@ void LiveActions::desktop_open_appointment(const Appointment& appt)
void LiveActions::desktop_open_calendar_app(const DateTime& dt)
{
- const auto day_begins = dt.add_full(0, 0, 0, -dt.hour(), -dt.minute(), -dt.seconds());
- const auto gmt = day_begins.to_timezone("UTC");
+ const auto gmt = dt.start_of_day().to_timezone("UTC");
auto cmd = gmt.format("evolution \"calendar:///?startdate=%Y%m%dT%H%M%SZ\"");
execute_command(cmd.c_str());
}
diff --git a/src/actions.cpp b/src/actions.cpp
index 1b665cc..41c7f11 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -143,9 +143,7 @@ void on_calendar_activated(GSimpleAction * /*action*/,
g_return_if_fail(t != 0);
- // the client gave us a date; remove the HMS component from the resulting DateTime
- auto dt = DateTime(t);
- dt = dt.add_full (0, 0, 0, -dt.hour(), -dt.minute(), -dt.seconds());
+ auto dt = DateTime(t).start_of_day();
static_cast<Actions*>(gself)->set_calendar_date(dt);
}
diff --git a/src/alarm-queue-simple.cpp b/src/alarm-queue-simple.cpp
index fa6c0bc..f45e61a 100644
--- a/src/alarm-queue-simple.cpp
+++ b/src/alarm-queue-simple.cpp
@@ -102,7 +102,7 @@ bool SimpleAlarmQueue::find_next_alarm(Appointment& setme) const
bool found = false;
Appointment tmp;
const auto now = m_clock->localtime();
- const auto beginning_of_minute = now.add_full (0, 0, 0, 0, 0, -now.seconds());
+ const auto beginning_of_minute = now.start_of_minute();
const auto appointments = m_planner->appointments().get();
g_debug ("planner has %zu appointments in it", (size_t)appointments.size());
diff --git a/src/menu.cpp b/src/menu.cpp
index f11de77..ff894bc 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -152,9 +152,9 @@ protected:
const auto now = m_state->clock->localtime();
const auto calendar_day = m_state->calendar_month->month().get();
if ((profile() == Desktop) && !DateTime::is_same_day(now, calendar_day))
- begin = calendar_day.add_full (0, 0, 0, -calendar_day.hour(), -calendar_day.minute(), -calendar_day.seconds());
+ begin = calendar_day.start_of_day();
else
- begin = now.add_full (0, 0, 0, 0, 0, -now.seconds());
+ begin = now.start_of_minute();
std::vector<Appointment> upcoming;
for(const auto& a : m_state->calendar_upcoming->appointments().get())
diff --git a/src/planner-month.cpp b/src/planner-month.cpp
index 5920daa..fd8a568 100644
--- a/src/planner-month.cpp
+++ b/src/planner-month.cpp
@@ -32,12 +32,7 @@ MonthPlanner::MonthPlanner(const std::shared_ptr<RangePlanner>& range_planner,
m_range_planner(range_planner)
{
month().changed().connect([this](const DateTime& m){
- auto month_begin = m.add_full(0, // no years
- 0, // no months
- -(m.day_of_month()-1),
- -m.hour(),
- -m.minute(),
- -m.seconds());
+ auto month_begin = m.start_of_day().add_full(0, 0, -(m.day_of_month()-1), 0, 0, 0);
auto month_end = month_begin.add_full(0, 1, 0, 0, 0, -0.1);
g_debug("PlannerMonth %p setting calendar month range: [%s..%s]", this, month_begin.format("%F %T").c_str(), month_end.format("%F %T").c_str());
m_range_planner->range().set(std::pair<DateTime,DateTime>(month_begin,month_end));
diff --git a/src/planner-upcoming.cpp b/src/planner-upcoming.cpp
index ed45955..338329c 100644
--- a/src/planner-upcoming.cpp
+++ b/src/planner-upcoming.cpp
@@ -33,7 +33,7 @@ UpcomingPlanner::UpcomingPlanner(const std::shared_ptr<RangePlanner>& range_plan
{
date().changed().connect([this](const DateTime& dt){
// set the range to the upcoming month
- const auto b = dt.add_full(0, 0, -1, -dt.hour(), -dt.minute(), -dt.seconds());
+ const auto b = dt.add_days(-1).start_of_day();
const auto e = b.add_full(0, 1, 0, 0, 0, 0);
g_debug("%p setting date range to [%s..%s]", this, b.format("%F %T").c_str(), e.format("%F %T").c_str());
m_range_planner->range().set(std::pair<DateTime,DateTime>(b,e));