mirror of
https://github.com/TakeV-Lambda/dino.git
synced 2024-11-04 14:57:44 +00:00
Fix for older glib versions
This commit is contained in:
parent
2e0357877c
commit
4f0ca55cf0
1 changed files with 13 additions and 2 deletions
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue