summaryrefslogtreecommitdiff
path: root/src/plugins/ruby/weechat-ruby-api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/ruby/weechat-ruby-api.c')
-rw-r--r--src/plugins/ruby/weechat-ruby-api.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c
index 17eb4f79e..6d5978e10 100644
--- a/src/plugins/ruby/weechat-ruby-api.c
+++ b/src/plugins/ruby/weechat-ruby-api.c
@@ -6382,7 +6382,6 @@ weechat_ruby_api_hdata_time (VALUE class, VALUE hdata, VALUE pointer,
{
char *c_hdata, *c_pointer, *c_name, timebuffer[64], *result;
time_t time;
- struct tm *date_tmp;
VALUE return_value;
API_FUNC(1, "hdata_time", API_RETURN_EMPTY);
@@ -6401,9 +6400,7 @@ weechat_ruby_api_hdata_time (VALUE class, VALUE hdata, VALUE pointer,
time = weechat_hdata_time (API_STR2PTR(c_hdata),
API_STR2PTR(c_pointer),
c_name);
- date_tmp = localtime (&time);
- if (date_tmp)
- strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
+ snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)time);
result = strdup (timebuffer);
API_RETURN_STRING_FREE(result);
@@ -6442,6 +6439,41 @@ weechat_ruby_api_hdata_hashtable (VALUE class, VALUE hdata, VALUE pointer,
}
/*
+ * weechat_ruby_api_hdata_update: update data in a hdata
+ */
+
+static VALUE
+weechat_ruby_api_hdata_update (VALUE class, VALUE hdata, VALUE pointer,
+ VALUE hashtable)
+{
+ char *c_hdata, *c_pointer;
+ struct t_hashtable *c_hashtable;
+ int value;
+
+ API_FUNC(1, "hdata_update", API_RETURN_INT(0));
+ if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (hashtable))
+ API_WRONG_ARGS(API_RETURN_INT(0));
+
+ Check_Type (hdata, T_STRING);
+ Check_Type (pointer, T_STRING);
+ Check_Type (hashtable, T_HASH);
+
+ c_hdata = StringValuePtr (hdata);
+ c_pointer = StringValuePtr (pointer);
+ c_hashtable = weechat_ruby_hash_to_hashtable (hashtable,
+ WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE);
+
+ value = weechat_hdata_update (API_STR2PTR(c_hdata),
+ API_STR2PTR(c_pointer),
+ c_hashtable);
+
+ if (c_hashtable)
+ weechat_hashtable_free (c_hashtable);
+
+ API_RETURN_INT(value);
+}
+
+/*
* weechat_ruby_api_hdata_get_string: get hdata property as string
*/
@@ -6859,6 +6891,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(hdata_pointer, 3);
API_DEF_FUNC(hdata_time, 3);
API_DEF_FUNC(hdata_hashtable, 3);
+ API_DEF_FUNC(hdata_update, 3);
API_DEF_FUNC(hdata_get_string, 2);
API_DEF_FUNC(upgrade_new, 2);
API_DEF_FUNC(upgrade_write_object, 3);