Class: Mysql::Time

Inherits:
Object
  • Object
show all
Defined in:
ext/mysql.c

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Object


Mysql::Time object method


1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
# File 'ext/mysql.c', line 1952

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



2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
# File 'ext/mysql.c', line 2025

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;
}

#dayObject

#day=Object

#hourObject

#hour=Object

#inspectObject



1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
# File 'ext/mysql.c', line 1968

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);
}

#minuteObject

#minute=Object

#monthObject

#month=Object

#negObject

#neg=Object

#secondObject

#second=Object

#second_partObject

#second_part=Object

#to_sObject



1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
# File 'ext/mysql.c', line 1981

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);
}

#yearObject

#year=Object