aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-10-27 16:19:59 +0100
committerfiaxh <git@lightrise.org>2020-10-27 16:19:59 +0100
commit4f0ca55cf021b5daa4efb8036d31778a0d043b28 (patch)
treeb1194902a15a05c5196f226d33116122e3216097
parent2e0357877cf3e8e391d3f8f02970defa93c710eb (diff)
downloaddino-4f0ca55cf021b5daa4efb8036d31778a0d043b28.tar.gz
dino-4f0ca55cf021b5daa4efb8036d31778a0d043b28.zip
Fix for older glib versions
-rw-r--r--xmpp-vala/src/module/xep/0082_date_time_profiles.vala15
1 files changed, 13 insertions, 2 deletions
diff --git a/xmpp-vala/src/module/xep/0082_date_time_profiles.vala b/xmpp-vala/src/module/xep/0082_date_time_profiles.vala
index 17ed9e09..32d4d3ac 100644
--- a/xmpp-vala/src/module/xep/0082_date_time_profiles.vala
+++ b/xmpp-vala/src/module/xep/0082_date_time_profiles.vala
@@ -1,12 +1,23 @@
namespace Xmpp.Xep.DateTimeProfiles {
public DateTime? parse_string(string time_string) {
- return new DateTime.from_iso8601(time_string, null);
+ // TODO with glib >= 2.56
+ // return new DateTime.from_iso8601(time_string, null);
+
+ TimeVal time_val = TimeVal();
+ if (time_val.from_iso8601(time_string)) {
+ return new DateTime.from_unix_utc(time_val.tv_sec);
+ }
+ return null;
+
}
public string to_datetime(DateTime time) {
- return time.to_utc().format_iso8601().to_string();
+ // TODO with glib >= 2.62
+ // return time.to_utc().format_iso8601().to_string();
+
+ return time.to_utc().format("%Y-%m-%dT%H:%M:%SZ");
}
}