aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/date-time.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/date-time.cpp b/src/date-time.cpp
index 54601d0..4930bf6 100644
--- a/src/date-time.cpp
+++ b/src/date-time.cpp
@@ -65,13 +65,13 @@ DateTime& DateTime::operator+=(const std::chrono::seconds& seconds)
return (*this = add_full(0, 0, 0, 0, 0, seconds.count()));
}
-DateTime::DateTime(time_t t)
+DateTime::DateTime(GTimeZone* gtz, time_t t)
{
- auto gtz = g_time_zone_new_local();
- auto gdt = g_date_time_new_from_unix_local(t);
+ auto utc = g_date_time_new_from_unix_utc(t);
+ auto gdt = g_date_time_to_timezone (utc, gtz);
reset(gtz, gdt);
- g_time_zone_unref(gtz);
g_date_time_unref(gdt);
+ g_date_time_unref(utc);
}
DateTime DateTime::NowLocal()
@@ -84,6 +84,16 @@ DateTime DateTime::NowLocal()
return dt;
}
+DateTime DateTime::Local(time_t t)
+{
+ auto gtz = g_time_zone_new_local();
+ auto gdt = g_date_time_new_from_unix_local(t);
+ DateTime dt(gtz, gdt);
+ g_time_zone_unref(gtz);
+ g_date_time_unref(gdt);
+ return dt;
+}
+
DateTime DateTime::Local(int year, int month, int day, int hour, int minute, double seconds)
{
auto gtz = g_time_zone_new_local();