class Mysql::Time

Public Class Methods

new(p1 = v1, p2 = v2, p3 = v3, p4 = v4, p5 = v5, p6 = v6, p7 = v7, p8 = v8) click to toggle source

Mysql::Time object method
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;
}

Public Instance Methods

==(p1) click to toggle source
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;
}
inspect() click to toggle source
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);
}
neg=(p1) click to toggle source
static VALUE time_set_neg(VALUE obj, VALUE v)
{
    rb_iv_set(obj, "neg", (v == Qnil || v == Qfalse) ? Qfalse : Qtrue);
    return v;
}
to_s() click to toggle source
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);
}