summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authorS-H-GAMELINKS <gamelinks007@gmail.com>2022-11-15 13:24:08 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-11-16 18:58:33 +0900
commit1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6 (patch)
tree823f1ca5409fdd930b05d974cdb70953b6e7e128 /time.c
parentdc1c4e46758ace2c9e5e822df0d64b16bb564bb4 (diff)
downloadruby-1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6.tar.gz
Using UNDEF_P macro
Diffstat (limited to 'time.c')
-rw-r--r--time.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/time.c b/time.c
index fe4ea00144..7d74b56a3b 100644
--- a/time.c
+++ b/time.c
@@ -523,7 +523,7 @@ num_exact(VALUE v)
return rb_rational_canonicalize(v);
default:
- if ((tmp = rb_check_funcall(v, idTo_r, 0, NULL)) != Qundef) {
+ if (!UNDEF_P(tmp = rb_check_funcall(v, idTo_r, 0, NULL))) {
/* test to_int method availability to reject non-Numeric
* objects such as String, Time, etc which have to_r method. */
if (!rb_respond_to(v, idTo_int)) {
@@ -2277,7 +2277,7 @@ zone_set_dst(VALUE zone, struct time_object *tobj, VALUE tm)
VALUE dst;
CONST_ID(id_dst_p, "dst?");
dst = rb_check_funcall(zone, id_dst_p, 1, &tm);
- tobj->vtm.isdst = (dst != Qundef && RTEST(dst));
+ tobj->vtm.isdst = (!UNDEF_P(dst) && RTEST(dst));
}
static int
@@ -2290,7 +2290,7 @@ zone_timelocal(VALUE zone, VALUE time)
t = rb_time_unmagnify(tobj->timew);
tm = tm_from_time(rb_cTimeTM, time);
utc = rb_check_funcall(zone, id_local_to_utc, 1, &tm);
- if (utc == Qundef) return 0;
+ if (UNDEF_P(utc)) return 0;
s = extract_time(utc);
zone_set_offset(zone, tobj, t, s);
@@ -2314,7 +2314,7 @@ zone_localtime(VALUE zone, VALUE time)
tm = tm_from_time(rb_cTimeTM, time);
local = rb_check_funcall(zone, id_utc_to_local, 1, &tm);
- if (local == Qundef) return 0;
+ if (UNDEF_P(local)) return 0;
s = extract_vtm(local, &tobj->vtm, subsecx);
tobj->tm_got = 1;
@@ -2616,7 +2616,7 @@ time_timespec(VALUE num, int interval)
else {
i = INT2FIX(1);
ary = rb_check_funcall(num, id_divmod, 1, &i);
- if (ary != Qundef && !NIL_P(ary = rb_check_array_type(ary))) {
+ if (!UNDEF_P(ary) && !NIL_P(ary = rb_check_array_type(ary))) {
i = rb_ary_entry(ary, 0);
f = rb_ary_entry(ary, 1);
t.tv_sec = NUM2TIMET(i);
@@ -5481,12 +5481,12 @@ rb_time_zone_abbreviation(VALUE zone, VALUE time)
tm = tm_from_time(rb_cTimeTM, time);
abbr = rb_check_funcall(zone, rb_intern("abbr"), 1, &tm);
- if (abbr != Qundef) {
+ if (!UNDEF_P(abbr)) {
goto found;
}
#ifdef SUPPORT_TZINFO_ZONE_ABBREVIATION
abbr = rb_check_funcall(zone, rb_intern("period_for_utc"), 1, &tm);
- if (abbr != Qundef) {
+ if (!UNDEF_P(abbr)) {
abbr = rb_funcallv(abbr, rb_intern("abbreviation"), 0, 0);
goto found;
}
@@ -5494,7 +5494,7 @@ rb_time_zone_abbreviation(VALUE zone, VALUE time)
strftime_args[0] = rb_fstring_lit("%Z");
strftime_args[1] = tm;
abbr = rb_check_funcall(zone, rb_intern("strftime"), 2, strftime_args);
- if (abbr != Qundef) {
+ if (!UNDEF_P(abbr)) {
goto found;
}
abbr = rb_check_funcall_default(zone, idName, 0, 0, Qnil);