aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/clock-live.cpp11
-rw-r--r--src/date-time.cpp11
-rw-r--r--src/engine-eds.cpp17
-rw-r--r--src/locations.cpp11
4 files changed, 49 insertions, 1 deletions
diff --git a/src/clock-live.cpp b/src/clock-live.cpp
index b6d7c12..710c58d 100644
--- a/src/clock-live.cpp
+++ b/src/clock-live.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Canonical Ltd.
+ * Copyright 2021 Robert Tari
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
@@ -15,6 +16,7 @@
*
* Authors:
* Charles Kerr <charles.kerr@canonical.com>
+ * Robert Tari <robert@tari.in>
*/
#include <datetime/clock.h>
@@ -162,7 +164,16 @@ private:
void setTimezone(const std::string& str)
{
g_clear_pointer(&m_gtimezone, g_time_zone_unref);
+ #if GLIB_CHECK_VERSION(2, 68, 0)
+ m_gtimezone = g_time_zone_new_identifier(str.c_str());
+
+ if (m_gtimezone == NULL)
+ {
+ m_gtimezone = g_time_zone_new_utc();
+ }
+ #else
m_gtimezone = g_time_zone_new(str.c_str());
+ #endif
m_owner.minute_changed();
}
diff --git a/src/date-time.cpp b/src/date-time.cpp
index 8493274..169426c 100644
--- a/src/date-time.cpp
+++ b/src/date-time.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Canonical Ltd.
+ * Copyright 2021 Robert Tari
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
@@ -15,6 +16,7 @@
*
* Authors:
* Charles Kerr <charles.kerr@canonical.com>
+ * Robert Tari <robert@tari.in>
*/
#include <datetime/date-time.h>
@@ -105,7 +107,16 @@ DateTime DateTime::Local(int year, int month, int day, int hour, int minute, dou
DateTime DateTime::to_timezone(const std::string& zone) const
{
+ #if GLIB_CHECK_VERSION(2, 68, 0)
+ auto gtz = g_time_zone_new_identifier(zone.c_str());
+
+ if (gtz == NULL)
+ {
+ gtz = g_time_zone_new_utc();
+ }
+ #else
auto gtz = g_time_zone_new(zone.c_str());
+ #endif
auto gdt = g_date_time_to_timezone(get(), gtz);
DateTime dt(gtz, gdt);
g_time_zone_unref(gtz);
diff --git a/src/engine-eds.cpp b/src/engine-eds.cpp
index 709bb4d..fc6a45b 100644
--- a/src/engine-eds.cpp
+++ b/src/engine-eds.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2014 Canonical Ltd.
+ * Copyright 2021 Robert Tari
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
@@ -15,6 +16,7 @@
*
* Authors:
* Charles Kerr <charles.kerr@canonical.com>
+ * Robert Tari <robert@tari.in>
*/
#include <datetime/engine-eds.h>
@@ -913,7 +915,20 @@ private:
if (identifier == nullptr)
g_warning("Unrecognized TZID: '%s'", tzid);
else
- return g_time_zone_new(identifier);
+ {
+ #if GLIB_CHECK_VERSION(2, 68, 0)
+ auto pZone = g_time_zone_new_identifier(identifier);
+
+ if (pZone == NULL)
+ {
+ pZone = g_time_zone_new_utc();
+ }
+ #else
+ auto pZone = g_time_zone_new(identifier);
+ #endif
+
+ return pZone;
+ }
return nullptr;
}
diff --git a/src/locations.cpp b/src/locations.cpp
index 94ccb23..a2dc564 100644
--- a/src/locations.cpp
+++ b/src/locations.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2013 Canonical Ltd.
+ * Copyright 2021 Robert Tari
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3, as published
@@ -15,6 +16,7 @@
*
* Authors:
* Charles Kerr <charles.kerr@canonical.com>
+ * Robert Tari <robert@tari.in>
*/
#include <datetime/locations.h>
@@ -47,7 +49,16 @@ Location::Location(const std::string& zone_, const std::string& name_):
m_zone(zone_),
m_name(name_)
{
+ #if GLIB_CHECK_VERSION(2, 68, 0)
+ auto gzone = g_time_zone_new_identifier(zone().c_str());
+
+ if (gzone == NULL)
+ {
+ gzone = g_time_zone_new_utc();
+ }
+ #else
auto gzone = g_time_zone_new (zone().c_str());
+ #endif
auto gtime = g_date_time_new_now (gzone);
m_offset = g_date_time_get_utc_offset (gtime);
g_date_time_unref (gtime);