[geary/gnumdk/glib_tz_identifier] engine: Fix GLib.Timezone deprecation warning in GLib 2.68
- From: Cédric Bellegarde <cbellegarde src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/gnumdk/glib_tz_identifier] engine: Fix GLib.Timezone deprecation warning in GLib 2.68
- Date: Fri, 15 Jul 2022 21:49:41 +0000 (UTC)
commit 42fa8c9f0a0673835a9c63ede5bdf20e8bb86c4f
Author: Michael Gratton <mike vee net>
Date: Tue Apr 6 12:36:46 2021 +1000
engine: Fix GLib.Timezone deprecation warning in GLib 2.68
meson.build | 2 +-
src/engine/imap/message/imap-internal-date.vala | 26 ++++++++++++++++++-------
2 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/meson.build b/meson.build
index ae8a84c79..1be205e31 100644
--- a/meson.build
+++ b/meson.build
@@ -53,7 +53,7 @@ valac = meson.get_compiler('vala')
# Required libraries and other dependencies
#
-target_glib = '2.66'
+target_glib = '2.68'
target_gtk = '3.24.23'
target_vala = '0.48.18'
target_webkit = '2.30'
diff --git a/src/engine/imap/message/imap-internal-date.vala b/src/engine/imap/message/imap-internal-date.vala
index e90e23d0c..e89b99c01 100644
--- a/src/engine/imap/message/imap-internal-date.vala
+++ b/src/engine/imap/message/imap-internal-date.vala
@@ -79,14 +79,26 @@ public class Geary.Imap.InternalDate : Geary.MessageData.AbstractMessageData, Ge
if (month < 0)
throw new ImapError.PARSE_ERROR("Invalid INTERNALDATE \"%s\": bad month", internaldate);
- // TODO: verify timezone
-
- // if no timezone listed, ISO 8601 says to use local time
- TimeZone timezone = (tz[0] != '\0') ? new TimeZone((string) tz) : new TimeZone.local();
+ GLib.TimeZone? timezone = null;
+ if (tz[0] != '\0') {
+ string tz_string = (string) tz;
+ try {
+ timezone = new GLib.TimeZone.identifier(tz_string);
+ } catch (GLib.Error err) {
+ warning("Invalid INTERNALDATE timezone \"%s\", %s", tz_string, err.message);
+ }
+ }
+ if (timezone == null) {
+ // If no timezone listed, ISO 8601 says to use local time.
+ timezone = new GLib.TimeZone.local();
+ }
- // assemble into DateTime, which validates the time as well (this is why we want to keep
- // original around, for other reasons) ... month is 1-based in DateTime
- DateTime datetime = new DateTime(timezone, year, month + 1, day, hour, min, sec);
+ // assemble into DateTime, which validates the time as well
+ // (this is why we want to keep original around, for other
+ // reasons) ... month is 1-based in DateTime
+ var datetime = new GLib.DateTime(
+ timezone, year, month + 1, day, hour, min, sec
+ );
return new InternalDate(internaldate, datetime);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]