summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-31 08:08:46 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-31 08:08:46 +0000
commit5f66e0959041f9256ac9d9e2775d76df099506f7 (patch)
tree447c9985cb770e41c633f08615b3534f78dfaf0a
parent12585d04771596124b0c2e96ed013406cc38fc83 (diff)
* time.c (time_dup): duplicate the class of original time.
[ruby-core:09357] * lib/time.rb (Time::make_time, Time::rfc2822, Time::httpdate): should respect subclasses. [ruby-core:09357] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--lib/time.rb10
-rw-r--r--time.c2
3 files changed, 14 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 2a93650d26..76e857575b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Tue Oct 31 17:03:21 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * time.c (time_dup): duplicate the class of original time.
+ [ruby-core:09357]
+
+ * lib/time.rb (Time::make_time, Time::rfc2822, Time::httpdate):
+ should respect subclasses. [ruby-core:09357]
+
Mon Oct 30 23:40:52 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
* Makefile.in (miniruby): add XLDFLAGS.
diff --git a/lib/time.rb b/lib/time.rb
index 3b4ee9e72a..dbc25f4193 100644
--- a/lib/time.rb
+++ b/lib/time.rb
@@ -181,7 +181,7 @@ class Time
t.localtime if !zone_utc?(zone)
t
else
- Time.local(year, mon, day, hour, min, sec, usec)
+ self.local(year, mon, day, hour, min, sec, usec)
end
end
private :make_time
@@ -289,7 +289,7 @@ class Time
year, mon, day, hour, min, sec =
apply_offset(year, mon, day, hour, min, sec, zone_offset(zone))
- t = Time.utc(year, mon, day, hour, min, sec)
+ t = self.utc(year, mon, day, hour, min, sec)
t.localtime if !zone_utc?(zone)
t
else
@@ -316,14 +316,14 @@ class Time
(\d{2}):(\d{2}):(\d{2})\x20
GMT
\s*\z/ix =~ date
- Time.rfc2822(date)
+ self.rfc2822(date)
elsif /\A\s*
(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday),\x20
(\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d)\x20
(\d\d):(\d\d):(\d\d)\x20
GMT
\s*\z/ix =~ date
- Time.parse(date)
+ self.parse(date)
elsif /\A\s*
(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\x20
(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\x20
@@ -331,7 +331,7 @@ class Time
(\d\d):(\d\d):(\d\d)\x20
(\d{4})
\s*\z/ix =~ date
- Time.utc($6.to_i, MonthValue[$1.upcase], $2.to_i,
+ self.utc($6.to_i, MonthValue[$1.upcase], $2.to_i,
$3.to_i, $4.to_i, $5.to_i)
else
raise ArgumentError.new("not RFC 2616 compliant date: #{date.inspect}")
diff --git a/time.c b/time.c
index b856228518..d919c631f4 100644
--- a/time.c
+++ b/time.c
@@ -1066,7 +1066,7 @@ static VALUE
time_dup(time)
VALUE time;
{
- VALUE dup = time_s_alloc(rb_cTime);
+ VALUE dup = time_s_alloc(CLASS_OF(time));
time_init_copy(dup, time);
return dup;
}