Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utils: Use GLib.TimeZone.identifier instead of deprecated Glib.TimeZone #395

Merged
merged 3 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tasks_deps = [
dependency('champlain-gtk-0.12'),
dependency('clutter-1.0'),
dependency('clutter-gtk-1.0'),
dependency('glib-2.0'),
dependency('glib-2.0', version: '>=2.68'),
dependency('gobject-2.0'),
dependency('granite', version: '>=6.2.0'),
dependency('gtk+-3.0'),
Expand Down
28 changes: 17 additions & 11 deletions src/Util.vala
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,18 @@ namespace Tasks.Util {
* will always return a GLib.TimeZone, which will be UTC if parsing
* fails for some reason.
*/
var prefix = "/freeassociation.sourceforge.net/";
if (tzid.has_prefix (prefix)) {
// TZID has prefix "/freeassociation.sourceforge.net/",
// indicating a libical TZID.
return new GLib.TimeZone (tzid.offset (prefix.length));
} else {
// TZID does not have libical prefix, potentially indicating an Olson
// standard city name.
return new GLib.TimeZone (tzid);
}
try {
var prefix = "/freeassociation.sourceforge.net/";
if (tzid.has_prefix (prefix)) {
// TZID has prefix "/freeassociation.sourceforge.net/",
// indicating a libical TZID.
return new GLib.TimeZone.identifier (tzid.offset (prefix.length));
} else {
// TZID does not have libical prefix, potentially indicating an Olson
// standard city name.
return new GLib.TimeZone.identifier (tzid);
}
} catch (Error e) {} // Fall through code deals with error
}
// If tzid fails, try ICal.Time.get_timezone ()
unowned ICal.Timezone? timezone = null;
Expand All @@ -191,7 +193,11 @@ namespace Tasks.Util {
var minutes = (interval % 3600) / 60;
var hour_string = "%s%02d:%02d".printf (is_positive ? "+" : "-", hours, minutes);

return new GLib.TimeZone (hour_string);
try {
return new GLib.TimeZone.identifier (hour_string);
} catch (Error e) {
return new GLib.TimeZone.local ();
}
}

/**
Expand Down