diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-05-24 01:09:36 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-05-24 01:09:36 +0900 |
| commit | ad9e841c5359efdd37a132767e03ad7a2d5ae72e (patch) | |
| tree | 8e60edf2dce29e86d8b47d0b2e8dc8a2a2329ded /src/time.c | |
| parent | 4f012f578f22cca67af8c633845464abc79913f4 (diff) | |
| download | mruby-ad9e841c5359efdd37a132767e03ad7a2d5ae72e.tar.gz mruby-ad9e841c5359efdd37a132767e03ad7a2d5ae72e.zip | |
made mrb_get_args() better (optinal args, type checks); close #173 #176
Diffstat (limited to 'src/time.c')
| -rw-r--r-- | src/time.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/time.c b/src/time.c index 293eef583..63b763a08 100644 --- a/src/time.c +++ b/src/time.c @@ -268,7 +268,7 @@ mrb_time_gm(mrb_state *mrb, mrb_value self) { mrb_int ayear = 0, amonth = 1, aday = 1, ahour = 0, amin = 0, asec = 0, ausec = 0; - mrb_get_args(mrb, "iiiiiii", + mrb_get_args(mrb, "i|iiiiii", &ayear, &amonth, &aday, &ahour, &amin, &asec, &ausec); return mrb_time_wrap(mrb, mrb_class_ptr(self), time_mktime(mrb, ayear, amonth, aday, ahour, amin, asec, ausec, MRB_TIMEZONE_UTC)); @@ -282,7 +282,7 @@ mrb_time_local(mrb_state *mrb, mrb_value self) { mrb_int ayear = 0, amonth = 1, aday = 1, ahour = 0, amin = 0, asec = 0, ausec = 0; - mrb_get_args(mrb, "iiiiiii", + mrb_get_args(mrb, "i|iiiiii", &ayear, &amonth, &aday, &ahour, &amin, &asec, &ausec); return mrb_time_wrap(mrb, mrb_class_ptr(self), time_mktime(mrb, ayear, amonth, aday, ahour, amin, asec, ausec, MRB_TIMEZONE_LOCAL)); @@ -352,7 +352,6 @@ mrb_time_minus(mrb_state *mrb, mrb_value self) struct mrb_time *tm; mrb_get_args(mrb, "f", &f); - tm = mrb_get_datatype(mrb, self, &mrb_time_type); if(!tm) return mrb_nil_value(); f -= tm->sec; @@ -499,8 +498,8 @@ static mrb_value mrb_time_initialize_copy(mrb_state *mrb, mrb_value copy) { mrb_value src; - mrb_get_args(mrb, "o", &src); + mrb_get_args(mrb, "o", &src); if (mrb_obj_equal(mrb, copy, src)) return copy; if (!mrb_obj_is_instance_of(mrb, src, mrb_obj_class(mrb, copy))) { mrb_raise(mrb, E_TYPE_ERROR, "wrong argument class"); |
