/* * Document-method: SimpleZDB.create_ztime * call-seq: * SimpleZDB.create_ztime(time) -> string or nil * * Wrapper of SlZDtm::SlZDataManager::createZTime(void*, int, int, int, int, int, int). * Used by FilterInfo#to_exp. */ static VALUE szdb_s_create_ztime(VALUE klass, VALUE time) { if (rb_respond_to(time, rb_intern("new_offset"))) { time = rb_funcall(time, rb_intern("new_offset"), 1, INT2FIX(0)); } else { time = rb_funcall(cDateTime, rb_intern("new"), 6, rb_funcall(time, rb_intern("year"), 0), rb_funcall(time, rb_intern("month"), 0), rb_funcall(time, rb_intern("day"), 0), INT2FIX(0), INT2FIX(0), INT2FIX(0)); } VALUE buf = rb_str_new("\0\0\0\0\0", 5); bool result = SlZDataManager::createZTime(RSTRING(buf)->ptr, NUM2INT(rb_funcall(time, rb_intern("year"), 0)), NUM2INT(rb_funcall(time, rb_intern("month"), 0)), NUM2INT(rb_funcall(time, rb_intern("day"), 0)), NUM2INT(rb_funcall(time, rb_intern("hour"), 0)), NUM2INT(rb_funcall(time, rb_intern("min"), 0)), NUM2INT(rb_funcall(time, rb_intern("sec"), 0))); return result ? buf : Qnil; }