[folks] inspect: Implement pretty printing of GDateTime
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] inspect: Implement pretty printing of GDateTime
- Date: Mon, 18 Jun 2012 09:34:08 +0000 (UTC)
commit 1c3357fb0c32855f5423e5b88127f2b4cfb1baa5
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Jun 18 10:32:49 2012 +0100
inspect: Implement pretty printing of GDateTime
The new Zeitgeist work in the Telepathy backend makes use of nullable
GDateTimes, so this implements pretty printing of them in folks-inspect.
Everyone prefers reading well-formatted ISO 8601 date/times over reading
error messages saying the conversion wasnât possible, right?
tools/inspect/utils.vala | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/tools/inspect/utils.vala b/tools/inspect/utils.vala
index d14c6ce..cf5f98c 100644
--- a/tools/inspect/utils.vala
+++ b/tools/inspect/utils.vala
@@ -39,6 +39,8 @@ private class Folks.Inspect.Utils
typeof (string), Utils.transform_persona_store_to_string);
Value.register_transform_func (typeof (string[]), typeof (string),
Utils.transform_string_array_to_string);
+ Value.register_transform_func (typeof (DateTime), typeof (string),
+ Utils.transform_date_time_to_string);
}
private static void transform_object_to_string (Value src,
@@ -74,6 +76,18 @@ private class Folks.Inspect.Utils
dest = (owned) output;
}
+ private static void transform_date_time_to_string (Value src, out Value dest)
+ {
+ unowned DateTime? date_time = (DateTime?) src;
+ string output = "(null)";
+ if (date_time != null)
+ {
+ output = ((!) date_time).format ("%FT%T%z");
+ }
+
+ dest = (owned) output;
+ }
+
public static void indent ()
{
/* We indent in increments of two spaces */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]