From: Jürg Billeter Date: Mon, 8 Dec 2008 23:21:23 +0000 (+0000) Subject: Improve Time.to_string method and add Time.format method X-Git-Tag: VALA_0_5_3~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=17a70d74ba92171befa14093e5329ee99573e166;p=thirdparty%2Fvala.git Improve Time.to_string method and add Time.format method 2008-12-09 Jürg Billeter * vapi/glib-2.0.vapi: Improve Time.to_string method and add Time.format method svn path=/trunk/; revision=2125 --- diff --git a/ChangeLog b/ChangeLog index 9b640f91b..8fd8675c3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-12-09 Jürg Billeter + + * vapi/glib-2.0.vapi: + + Improve Time.to_string method and add Time.format method + 2008-12-09 Jürg Billeter * gobject/valaccodemethodmodule.vala: diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi index 3dedc44a6..ab7aae11b 100644 --- a/vapi/glib-2.0.vapi +++ b/vapi/glib-2.0.vapi @@ -1697,13 +1697,20 @@ namespace GLib { [CCode (cname = "localtime_r", instance_pos = -1)] public Time.local (time_t time); - [CCode (cname = "asctime_r")] - public string to_string (char* buffer = new char[26]); + public string to_string () { + return "%04d-%02d-%02d %02d:%02d:%02d".printf (year + 1900, month + 1, day, hour, minute, second); + } + + public string format (string format) { + var buffer = new char[64]; + this.strftime (buffer, format); + return (string) buffer; + } [CCode (cname = "mktime")] public time_t mktime (); - [CCode (instance_pos = -1)] + [CCode (cname = "strftime", instance_pos = -1)] public size_t strftime (char[] s, string format); [CCode (instance_pos = -1)] public weak string? strptime (string buf, string format);