aboutsummaryrefslogtreecommitdiff
path: root/src/date-time.cpp
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-03-14 17:37:00 +0000
committerCI bot <ps-jenkins@lists.canonical.com>2014-03-14 17:37:00 +0000
commit9f3136ba1c79020c10e58fa53e87a84bcce7dc29 (patch)
treefa0c19e8e5c7f362b7a04f0ad3e6f57d96c1462c /src/date-time.cpp
parent39d8fc602053397a3596d6d35afb5738b09b05a6 (diff)
parent35b0a3601f1d7d9f757467ffc7b909c461c2f49d (diff)
downloadayatana-indicator-datetime-9f3136ba1c79020c10e58fa53e87a84bcce7dc29.tar.gz
ayatana-indicator-datetime-9f3136ba1c79020c10e58fa53e87a84bcce7dc29.tar.bz2
ayatana-indicator-datetime-9f3136ba1c79020c10e58fa53e87a84bcce7dc29.zip
When the user clicks on a date in the calendar, update the "Upcoming Events" section to show events starting at that date. Fixes: 1290169, 1290171, 1291468
Diffstat (limited to 'src/date-time.cpp')
-rw-r--r--src/date-time.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/date-time.cpp b/src/date-time.cpp
index 432d877..a1c1d1b 100644
--- a/src/date-time.cpp
+++ b/src/date-time.cpp
@@ -46,14 +46,22 @@ DateTime& DateTime::operator=(const DateTime& that)
DateTime::DateTime(time_t t)
{
- GDateTime * gdt = g_date_time_new_from_unix_local(t);
+ auto gdt = g_date_time_new_from_unix_local(t);
reset(gdt);
g_date_time_unref(gdt);
}
DateTime DateTime::NowLocal()
{
- GDateTime * gdt = g_date_time_new_now_local();
+ auto gdt = g_date_time_new_now_local();
+ DateTime dt(gdt);
+ g_date_time_unref(gdt);
+ return dt;
+}
+
+DateTime DateTime::Local(int year, int month, int day, int hour, int minute, int seconds)
+{
+ auto gdt = g_date_time_new_local (year, month, day, hour, minute, seconds);
DateTime dt(gdt);
g_date_time_unref(gdt);
return dt;
@@ -97,11 +105,26 @@ std::string DateTime::format(const std::string& fmt) const
return ret;
}
+void DateTime::ymd(int& year, int& month, int& day) const
+{
+ g_date_time_get_ymd(get(), &year, &month, &day);
+}
+
int DateTime::day_of_month() const
{
return g_date_time_get_day_of_month(get());
}
+int DateTime::hour() const
+{
+ return g_date_time_get_hour(get());
+}
+
+int DateTime::minute() const
+{
+ return g_date_time_get_minute(get());
+}
+
double DateTime::seconds() const
{
return g_date_time_get_seconds(get());