aboutsummaryrefslogtreecommitdiff
path: root/include/datetime
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2015-03-14 21:20:30 -0500
committerCharles Kerr <charles.kerr@canonical.com>2015-03-14 21:20:30 -0500
commitdb5b700c7c116c73283019b3fbf823a23639a405 (patch)
tree4ae03eb86bb71a9453286e015fcedd00774b2bca /include/datetime
parent15ec7f61fa84a9a8b40c1c9fcfa6c2a268d3232b (diff)
downloadayatana-indicator-datetime-db5b700c7c116c73283019b3fbf823a23639a405.tar.gz
ayatana-indicator-datetime-db5b700c7c116c73283019b3fbf823a23639a405.tar.bz2
ayatana-indicator-datetime-db5b700c7c116c73283019b3fbf823a23639a405.zip
Add DateTime::start_of_day() to use instead of the add_hours(-hours()) trick, which doesn't work on days when DST changes.
Implementing this requires DateTime objects to keep their own GTimeZone pointer, since the one inside GDateTime is private and can't be used for DateTime::start_of_day()'s call to g_date_time_new(). As a result the public API of DateTime changes, since we'll need a GTimeZone when constructing or assigning from a GDateTime pointer.
Diffstat (limited to 'include/datetime')
-rw-r--r--include/datetime/date-time.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/include/datetime/date-time.h b/include/datetime/date-time.h
index 4be35f7..6e73ff3 100644
--- a/include/datetime/date-time.h
+++ b/include/datetime/date-time.h
@@ -38,13 +38,15 @@ public:
static DateTime NowLocal();
static DateTime Local(int years, int months, int days, int hours, int minutes, int seconds);
+ DateTime();
explicit DateTime(time_t t);
- explicit DateTime(GDateTime* in=nullptr);
- DateTime& operator=(GDateTime* in);
+ DateTime(GTimeZone* tz, GDateTime* dt);
DateTime& operator=(const DateTime& in);
DateTime to_timezone(const std::string& zone) const;
+ DateTime start_of_day() const;
+ DateTime start_of_minute() const;
+ DateTime add_days(int days) const;
DateTime add_full(int years, int months, int days, int hours, int minutes, double seconds) const;
- void reset(GDateTime* in=nullptr);
GDateTime* get() const;
GDateTime* operator()() const {return get();}
@@ -69,6 +71,8 @@ public:
bool is_set() const { return m_dt != nullptr; }
private:
+ void reset(GTimeZone*, GDateTime*);
+ std::shared_ptr<GTimeZone> m_tz;
std::shared_ptr<GDateTime> m_dt;
};