Class: Mysql::Time
- Inherits:
-
Object
- Object
- Mysql::Time
- Defined in:
- ext/mysql.c
Instance Method Summary collapse
- #==(v) ⇒ Object
- #day ⇒ Object
- #day= ⇒ Object
- #hour ⇒ Object
- #hour= ⇒ Object
-
#initialize(*args) ⇒ Object
constructor
——————————- Mysql::Time object method.
- #inspect ⇒ Object
- #minute ⇒ Object
- #minute= ⇒ Object
- #month ⇒ Object
- #month= ⇒ Object
- #neg ⇒ Object
- #neg= ⇒ Object
- #second ⇒ Object
- #second= ⇒ Object
- #second_part ⇒ Object
- #second_part= ⇒ Object
- #to_s ⇒ Object
- #year ⇒ Object
- #year= ⇒ Object
Constructor Details
#initialize(*args) ⇒ Object
2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 |
# File 'ext/mysql.c', line 2277
static VALUE time_initialize(int argc, VALUE* argv, VALUE obj)
{
VALUE year, month, day, hour, minute, second, neg, second_part;
rb_scan_args(argc, argv, "08", &year, &month, &day, &hour, &minute, &second, &neg, &second_part);
#define NILorFIXvalue(o) (NIL_P(o) ? INT2FIX(0) : (Check_Type(o, T_FIXNUM), o))
rb_iv_set(obj, "year", NILorFIXvalue(year));
rb_iv_set(obj, "month", NILorFIXvalue(month));
rb_iv_set(obj, "day", NILorFIXvalue(day));
rb_iv_set(obj, "hour", NILorFIXvalue(hour));
rb_iv_set(obj, "minute", NILorFIXvalue(minute));
rb_iv_set(obj, "second", NILorFIXvalue(second));
rb_iv_set(obj, "neg", (neg == Qnil || neg == Qfalse) ? Qfalse : Qtrue);
rb_iv_set(obj, "second_part", NILorFIXvalue(second_part));
return obj;
}
|
Instance Method Details
#==(v) ⇒ Object
2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 |
# File 'ext/mysql.c', line 2350
static VALUE time_equal(VALUE obj, VALUE v)
{
if (CLASS_OF(v) == cMysqlTime &&
NUM2INT(rb_iv_get(obj, "year")) == NUM2INT(rb_iv_get(v, "year")) &&
NUM2INT(rb_iv_get(obj, "month")) == NUM2INT(rb_iv_get(v, "month")) &&
NUM2INT(rb_iv_get(obj, "day")) == NUM2INT(rb_iv_get(v, "day")) &&
NUM2INT(rb_iv_get(obj, "hour")) == NUM2INT(rb_iv_get(v, "hour")) &&
NUM2INT(rb_iv_get(obj, "minute")) == NUM2INT(rb_iv_get(v, "minute")) &&
NUM2INT(rb_iv_get(obj, "second")) == NUM2INT(rb_iv_get(v, "second")) &&
rb_iv_get(obj, "neg") == rb_iv_get(v, "neg") &&
NUM2INT(rb_iv_get(obj, "second_part")) == NUM2INT(rb_iv_get(v, "second_part")))
return Qtrue;
return Qfalse;
}
|
#day ⇒ Object
#day= ⇒ Object
#hour ⇒ Object
#hour= ⇒ Object
#inspect ⇒ Object
2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 |
# File 'ext/mysql.c', line 2293
static VALUE time_inspect(VALUE obj)
{
char buf[36];
sprintf(buf, "#<Mysql::Time:%04d-%02d-%02d %02d:%02d:%02d>",
NUM2INT(rb_iv_get(obj, "year")),
NUM2INT(rb_iv_get(obj, "month")),
NUM2INT(rb_iv_get(obj, "day")),
NUM2INT(rb_iv_get(obj, "hour")),
NUM2INT(rb_iv_get(obj, "minute")),
NUM2INT(rb_iv_get(obj, "second")));
return rb_str_new2(buf);
}
|
#minute ⇒ Object
#minute= ⇒ Object
#month ⇒ Object
#month= ⇒ Object
#neg ⇒ Object
#neg= ⇒ Object
#second ⇒ Object
#second= ⇒ Object
#second_part ⇒ Object
#second_part= ⇒ Object
#to_s ⇒ Object
2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 |
# File 'ext/mysql.c', line 2306
static VALUE time_to_s(VALUE obj)
{
char buf[20];
sprintf(buf, "%04d-%02d-%02d %02d:%02d:%02d",
NUM2INT(rb_iv_get(obj, "year")),
NUM2INT(rb_iv_get(obj, "month")),
NUM2INT(rb_iv_get(obj, "day")),
NUM2INT(rb_iv_get(obj, "hour")),
NUM2INT(rb_iv_get(obj, "minute")),
NUM2INT(rb_iv_get(obj, "second")));
return rb_str_new2(buf);
}
|