engine: Fix GLib.Timezone deprecation warning in GLib 2.68

This commit is contained in:
Michael Gratton 2021-04-06 12:36:46 +10:00 committed by Cédric Bellegarde
parent fa99f13900
commit 42fa8c9f0a
2 changed files with 20 additions and 8 deletions

View file

@ -53,7 +53,7 @@ valac = meson.get_compiler('vala')
# Required libraries and other dependencies # Required libraries and other dependencies
# #
target_glib = '2.66' target_glib = '2.68'
target_gtk = '3.24.23' target_gtk = '3.24.23'
target_vala = '0.48.18' target_vala = '0.48.18'
target_webkit = '2.30' target_webkit = '2.30'

View file

@ -79,14 +79,26 @@ public class Geary.Imap.InternalDate : Geary.MessageData.AbstractMessageData, Ge
if (month < 0) if (month < 0)
throw new ImapError.PARSE_ERROR("Invalid INTERNALDATE \"%s\": bad month", internaldate); throw new ImapError.PARSE_ERROR("Invalid INTERNALDATE \"%s\": bad month", internaldate);
// TODO: verify timezone 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();
}
// if no timezone listed, ISO 8601 says to use local time // assemble into DateTime, which validates the time as well
TimeZone timezone = (tz[0] != '\0') ? new TimeZone((string) tz) : new TimeZone.local(); // (this is why we want to keep original around, for other
// reasons) ... month is 1-based in DateTime
// assemble into DateTime, which validates the time as well (this is why we want to keep var datetime = new GLib.DateTime(
// original around, for other reasons) ... month is 1-based in DateTime timezone, year, month + 1, day, hour, min, sec
DateTime datetime = new DateTime(timezone, year, month + 1, day, hour, min, sec); );
return new InternalDate(internaldate, datetime); return new InternalDate(internaldate, datetime);
} }