summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-23 12:43:07 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-10-23 12:43:07 (GMT)
commitfc3b500fb12f663e5c8510471e1c8c406c360074 (patch)
tree6ed91a7e7b03e44a94a17b958c1ff951e876669d
parentab20aee573322b0a67e67d45012d8625e4edf41c (diff)
Let Time::TM share the implementation with Time
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--time.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/time.c b/time.c
index 0a492f1..f801ee5 100644
--- a/time.c
+++ b/time.c
@@ -5304,7 +5304,36 @@ Init_Time(void)
rb_include_module(rb_cTime, rb_mComparable);
#if TM_IS_TIME
- rb_cTimeTM = rb_define_class_under(rb_cTime, "TM", rb_cTime);
+ rb_cTimeTM = rb_define_class_under(rb_cTime, "TM", rb_cObject);
+ rb_define_alloc_func(rb_cTimeTM, time_s_alloc);
+ rb_define_method(rb_cTimeTM, "sec", time_sec, 0);
+ rb_define_method(rb_cTimeTM, "min", time_min, 0);
+ rb_define_method(rb_cTimeTM, "hour", time_hour, 0);
+ rb_define_method(rb_cTimeTM, "mday", time_mday, 0);
+ rb_define_method(rb_cTimeTM, "day", time_mday, 0);
+ rb_define_method(rb_cTimeTM, "mon", time_mon, 0);
+ rb_define_method(rb_cTimeTM, "month", time_mon, 0);
+ rb_define_method(rb_cTimeTM, "year", time_year, 0);
+ rb_define_method(rb_cTimeTM, "isdst", time_isdst, 0);
+ rb_define_method(rb_cTimeTM, "dst?", time_isdst, 0);
+ rb_define_method(rb_cTimeTM, "zone", time_zone, 0);
+ rb_define_method(rb_cTimeTM, "gmtoff", rb_time_utc_offset, 0);
+ rb_define_method(rb_cTimeTM, "gmt_offset", rb_time_utc_offset, 0);
+ rb_define_method(rb_cTimeTM, "utc_offset", rb_time_utc_offset, 0);
+ rb_define_method(rb_cTimeTM, "utc?", time_utc_p, 0);
+ rb_define_method(rb_cTimeTM, "gmt?", time_utc_p, 0);
+ rb_define_method(rb_cTimeTM, "to_s", time_to_s, 0);
+ rb_define_method(rb_cTimeTM, "inspect", time_to_s, 0);
+ rb_define_method(rb_cTimeTM, "to_a", time_to_a, 0);
+ rb_define_method(rb_cTimeTM, "tv_sec", time_to_i, 0);
+ rb_define_method(rb_cTimeTM, "tv_usec", time_usec, 0);
+ rb_define_method(rb_cTimeTM, "usec", time_usec, 0);
+ rb_define_method(rb_cTimeTM, "tv_nsec", time_nsec, 0);
+ rb_define_method(rb_cTimeTM, "nsec", time_nsec, 0);
+ rb_define_method(rb_cTimeTM, "subsec", time_subsec, 0);
+ rb_define_method(rb_cTimeTM, "to_i", time_to_i, 0);
+ rb_define_method(rb_cTimeTM, "to_f", time_to_f, 0);
+ rb_define_method(rb_cTimeTM, "to_r", time_to_r, 0);
#else
rb_cTimeTM = rb_struct_define_under(rb_cTime, "TM",
"sec", "min", "hour",