aboutsummaryrefslogtreecommitdiff
path: root/src/date-time.cpp
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2021-06-18 02:48:29 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-06-27 07:30:50 +0200
commit17aa86ab53e3e49cd47116f9640c89484167abcd (patch)
treec52cf7026599e68b10c533f568b132864e8573c4 /src/date-time.cpp
parentb0d110bac6f1f10a949abb7f985ea4becda75488 (diff)
downloadayatana-indicator-datetime-17aa86ab53e3e49cd47116f9640c89484167abcd.tar.gz
ayatana-indicator-datetime-17aa86ab53e3e49cd47116f9640c89484167abcd.tar.bz2
ayatana-indicator-datetime-17aa86ab53e3e49cd47116f9640c89484167abcd.zip
If possible, avoid deprecated g_time_zone_new
fixes https://github.com/AyatanaIndicators/ayatana-indicator-datetime/issues/34
Diffstat (limited to 'src/date-time.cpp')
-rw-r--r--src/date-time.cpp11
1 files changed, 11 insertions, 0 deletions
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);