aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-06-27 07:32:39 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-06-27 07:32:39 +0200
commit66fdcd86c7de338563e5da1477481a940ab3bd52 (patch)
treec52cf7026599e68b10c533f568b132864e8573c4
parentb0d110bac6f1f10a949abb7f985ea4becda75488 (diff)
parent17aa86ab53e3e49cd47116f9640c89484167abcd (diff)
downloadayatana-indicator-datetime-66fdcd86c7de338563e5da1477481a940ab3bd52.tar.gz
ayatana-indicator-datetime-66fdcd86c7de338563e5da1477481a940ab3bd52.tar.bz2
ayatana-indicator-datetime-66fdcd86c7de338563e5da1477481a940ab3bd52.zip
Merge branch 'tari01-pr/fix-g-time-zone-new'
Attributes GH PR #41: https://github.com/AyatanaIndicators/ayatana-indicator-datetime/pull/41
-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
-rw-r--r--tests/test-clock.cpp22
-rw-r--r--tests/test-datetime.cpp2
-rw-r--r--tests/test-eds-ics-all-day-events.cpp11
-rw-r--r--tests/test-eds-ics-missing-trigger.cpp11
-rw-r--r--tests/test-eds-ics-nonrepeating-events.cpp11
-rw-r--r--tests/test-eds-ics-repeating-events.cpp11
-rw-r--r--tests/test-eds-ics-repeating-valarms.cpp11
-rw-r--r--tests/test-eds-ics-tzids-2.cpp11
-rw-r--r--tests/test-eds-ics-tzids.cpp11
13 files changed, 148 insertions, 3 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);
diff --git a/tests/test-clock.cpp b/tests/test-clock.cpp
index 44f9be0..54ff229 100644
--- a/tests/test-clock.cpp
+++ b/tests/test-clock.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>
@@ -77,8 +79,16 @@ TEST_F(ClockFixture, TimezoneChangeTriggersSkew)
auto timezone_ = std::make_shared<MockTimezone>();
timezone_->timezone.set("America/New_York");
LiveClock clock(timezone_);
-
+ #if GLIB_CHECK_VERSION(2, 68, 0)
+ auto tz_nyc = g_time_zone_new_identifier("America/New_York");
+
+ if (tz_nyc == NULL)
+ {
+ tz_nyc = g_time_zone_new_utc();
+ }
+ #else
auto tz_nyc = g_time_zone_new("America/New_York");
+ #endif
auto now_nyc = g_date_time_new_now(tz_nyc);
auto now = clock.localtime();
EXPECT_EQ(g_date_time_get_utc_offset(now_nyc), g_date_time_get_utc_offset(now.get()));
@@ -95,8 +105,16 @@ TEST_F(ClockFixture, TimezoneChangeTriggersSkew)
return G_SOURCE_REMOVE;
}, timezone_.get());
g_main_loop_run(loop);
-
+ #if GLIB_CHECK_VERSION(2, 68, 0)
+ auto tz_la = g_time_zone_new_identifier("America/Los_Angeles");
+
+ if (tz_la == NULL)
+ {
+ tz_la = g_time_zone_new_utc();
+ }
+ #else
auto tz_la = g_time_zone_new("America/Los_Angeles");
+ #endif
auto now_la = g_date_time_new_now(tz_la);
now = clock.localtime();
EXPECT_EQ(g_date_time_get_utc_offset(now_la), g_date_time_get_utc_offset(now.get()));
diff --git a/tests/test-datetime.cpp b/tests/test-datetime.cpp
index 665f861..d2fb6c1 100644
--- a/tests/test-datetime.cpp
+++ b/tests/test-datetime.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2015 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>
diff --git a/tests/test-eds-ics-all-day-events.cpp b/tests/test-eds-ics-all-day-events.cpp
index c327f1a..68a3c95 100644
--- a/tests/test-eds-ics-all-day-events.cpp
+++ b/tests/test-eds-ics-all-day-events.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2015 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 <algorithm>
@@ -46,7 +48,16 @@ TEST_F(VAlarmFixture, MultipleAppointments)
// we need a consistent timezone for the planner and our local DateTimes
constexpr char const * zone_str {"America/Chicago"};
auto tz = std::make_shared<MockTimezone>(zone_str);
+ #if GLIB_CHECK_VERSION(2, 68, 0)
+ auto gtz = g_time_zone_new_identifier(zone_str);
+
+ if (gtz == NULL)
+ {
+ gtz = g_time_zone_new_utc();
+ }
+ #else
auto gtz = g_time_zone_new(zone_str);
+ #endif
// make a planner that looks at the first half of 2015 in EDS
auto planner = std::make_shared<SimpleRangePlanner>(engine, tz);
diff --git a/tests/test-eds-ics-missing-trigger.cpp b/tests/test-eds-ics-missing-trigger.cpp
index b45836f..0aa00c6 100644
--- a/tests/test-eds-ics-missing-trigger.cpp
+++ b/tests/test-eds-ics-missing-trigger.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2015 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 <algorithm>
@@ -46,7 +48,16 @@ TEST_F(VAlarmFixture, MissingTriggers)
// we need a consistent timezone for the planner and our local DateTimes
constexpr char const * zone_str {"America/Chicago"};
auto tz = std::make_shared<MockTimezone>(zone_str);
+ #if GLIB_CHECK_VERSION(2, 68, 0)
+ auto gtz = g_time_zone_new_identifier(zone_str);
+
+ if (gtz == NULL)
+ {
+ gtz = g_time_zone_new_utc();
+ }
+ #else
auto gtz = g_time_zone_new(zone_str);
+ #endif
// make a planner that looks at the first half of 2015 in EDS
auto planner = std::make_shared<SimpleRangePlanner>(engine, tz);
diff --git a/tests/test-eds-ics-nonrepeating-events.cpp b/tests/test-eds-ics-nonrepeating-events.cpp
index 55fce6c..e79ab1a 100644
--- a/tests/test-eds-ics-nonrepeating-events.cpp
+++ b/tests/test-eds-ics-nonrepeating-events.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2015 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 <algorithm>
@@ -46,7 +48,16 @@ TEST_F(VAlarmFixture, MultipleAppointments)
// we need a consistent timezone for the planner and our local DateTimes
constexpr char const * zone_str {"America/Chicago"};
auto tz = std::make_shared<MockTimezone>(zone_str);
+ #if GLIB_CHECK_VERSION(2, 68, 0)
+ auto gtz = g_time_zone_new_identifier(zone_str);
+
+ if (gtz == NULL)
+ {
+ gtz = g_time_zone_new_utc();
+ }
+ #else
auto gtz = g_time_zone_new(zone_str);
+ #endif
// make a planner that looks at the first half of 2015 in EDS
auto planner = std::make_shared<SimpleRangePlanner>(engine, tz);
diff --git a/tests/test-eds-ics-repeating-events.cpp b/tests/test-eds-ics-repeating-events.cpp
index 6c021f7..d4f0026 100644
--- a/tests/test-eds-ics-repeating-events.cpp
+++ b/tests/test-eds-ics-repeating-events.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2015 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 <algorithm>
@@ -46,7 +48,16 @@ TEST_F(VAlarmFixture, MultipleAppointments)
// we need a consistent timezone for the planner and our local DateTimes
constexpr char const * zone_str {"America/Chicago"};
auto tz = std::make_shared<MockTimezone>(zone_str);
+ #if GLIB_CHECK_VERSION(2, 68, 0)
+ auto gtz = g_time_zone_new_identifier(zone_str);
+
+ if (gtz == NULL)
+ {
+ gtz = g_time_zone_new_utc();
+ }
+ #else
auto gtz = g_time_zone_new(zone_str);
+ #endif
// make a planner that looks at the first half of 2015 in EDS
auto planner = std::make_shared<SimpleRangePlanner>(engine, tz);
diff --git a/tests/test-eds-ics-repeating-valarms.cpp b/tests/test-eds-ics-repeating-valarms.cpp
index d4b8b83..2132b71 100644
--- a/tests/test-eds-ics-repeating-valarms.cpp
+++ b/tests/test-eds-ics-repeating-valarms.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2015 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 <algorithm>
@@ -46,7 +48,16 @@ TEST_F(VAlarmFixture, MultipleAppointments)
// we need a consistent timezone for the planner and our local DateTimes
constexpr char const * zone_str {"America/Chicago"};
auto tz = std::make_shared<MockTimezone>(zone_str);
+ #if GLIB_CHECK_VERSION(2, 68, 0)
+ auto gtz = g_time_zone_new_identifier(zone_str);
+
+ if (gtz == NULL)
+ {
+ gtz = g_time_zone_new_utc();
+ }
+ #else
auto gtz = g_time_zone_new(zone_str);
+ #endif
// make a planner that looks at the first half of 2015 in EDS
auto planner = std::make_shared<SimpleRangePlanner>(engine, tz);
diff --git a/tests/test-eds-ics-tzids-2.cpp b/tests/test-eds-ics-tzids-2.cpp
index c0572d0..c8b0370 100644
--- a/tests/test-eds-ics-tzids-2.cpp
+++ b/tests/test-eds-ics-tzids-2.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2015 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 <algorithm>
@@ -46,7 +48,16 @@ TEST_F(VAlarmFixture, MultipleAppointments)
// we need a consistent timezone for the planner and our local DateTimes
constexpr char const * zone_str {"America/Los_Angeles"};
auto tz = std::make_shared<MockTimezone>(zone_str);
+ #if GLIB_CHECK_VERSION(2, 68, 0)
+ auto gtz = g_time_zone_new_identifier(zone_str);
+
+ if (gtz == NULL)
+ {
+ gtz = g_time_zone_new_utc();
+ }
+ #else
auto gtz = g_time_zone_new(zone_str);
+ #endif
// make a planner that looks at the first half of 2015 in EDS
auto planner = std::make_shared<SimpleRangePlanner>(engine, tz);
diff --git a/tests/test-eds-ics-tzids.cpp b/tests/test-eds-ics-tzids.cpp
index 41d8214..c80feb2 100644
--- a/tests/test-eds-ics-tzids.cpp
+++ b/tests/test-eds-ics-tzids.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2015 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 <algorithm>
@@ -46,7 +48,16 @@ TEST_F(VAlarmFixture, MultipleAppointments)
// we need a consistent timezone for the planner and our local DateTimes
constexpr char const * zone_str {"Europe/Berlin"};
auto tz = std::make_shared<MockTimezone>(zone_str);
+ #if GLIB_CHECK_VERSION(2, 68, 0)
+ auto gtz = g_time_zone_new_identifier(zone_str);
+
+ if (gtz == NULL)
+ {
+ gtz = g_time_zone_new_utc();
+ }
+ #else
auto gtz = g_time_zone_new(zone_str);
+ #endif
// make a planner that looks at the first half of 2015 in EDS
auto planner = std::make_shared<SimpleRangePlanner>(engine, tz);