anotherim-desktop/xmpp-vala/src/module/xep/0082_date_time_profiles.vala

24 lines
542 B
Vala
Raw Normal View History

namespace Xmpp.Xep.DateTimeProfiles {
2017-08-16 09:44:42 +00:00
public DateTime? parse_string(string time_string) {
2020-10-27 15:19:59 +00:00
// 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;
2017-08-16 09:44:42 +00:00
}
2017-08-22 10:13:11 +00:00
2017-08-12 21:14:50 +00:00
public string to_datetime(DateTime time) {
2020-10-27 15:19:59 +00:00
// TODO with glib >= 2.62
// return time.to_utc().format_iso8601().to_string();
return time.to_utc().format("%Y-%m-%dT%H:%M:%SZ");
}
2017-08-12 21:14:50 +00:00
}