summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-29 02:54:38 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-29 02:54:38 +0000
commit18b9473a6cf09fae0a75e88d4ac64177bd32ed47 (patch)
treec4f90ef4fb3ede31938f1232f474ec0206e1d408
parent8e7303ae4ef0e4b4d8fa6c482fc3e1d2cce78f3d (diff)
merge revision(s) 19707:
* lib/date.rb (today,now): should produce own instances. [ruby-talk:317020] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@21866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/date.rb15
-rw-r--r--version.h8
3 files changed, 22 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index e3661adeb5..9fb82fd23f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Jan 29 11:54:22 2009 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * lib/date.rb (today,now): should produce own instances.
+ [ruby-talk:317020]
+
Wed Jan 28 22:51:55 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_mod_modfunc): method undefined in included module
diff --git a/lib/date.rb b/lib/date.rb
index 90a4a01ca3..19991d60b4 100644
--- a/lib/date.rb
+++ b/lib/date.rb
@@ -1660,12 +1660,23 @@ class Date
# Create a new Date object representing today.
#
# +sg+ specifies the Day of Calendar Reform.
- def self.today(sg=ITALY) Time.now.__send__(:to_date) .new_start(sg) end
+ def self.today(sg=ITALY)
+ t = Time.now
+ jd = civil_to_jd(t.year, t.mon, t.mday, sg)
+ new!(jd_to_ajd(jd, 0, 0), 0, sg)
+ end
# Create a new DateTime object representing the current time.
#
# +sg+ specifies the Day of Calendar Reform.
- def self.now (sg=ITALY) Time.now.__send__(:to_datetime).new_start(sg) end
+ def self.now(sg=ITALY)
+ t = Time.now
+ jd = civil_to_jd(t.year, t.mon, t.mday, sg)
+ fr = time_to_day_fraction(t.hour, t.min, [t.sec, 59].min) +
+ Rational(t.usec, 86400_000_000)
+ of = Rational(t.utc_offset, 86400)
+ new!(jd_to_ajd(jd, fr, of), of, sg)
+ end
private_class_method :now
diff --git a/version.h b/version.h
index 3a90eee69d..fc4754c04e 100644
--- a/version.h
+++ b/version.h
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.8.7"
-#define RUBY_RELEASE_DATE "2009-01-28"
+#define RUBY_RELEASE_DATE "2009-01-29"
#define RUBY_VERSION_CODE 187
-#define RUBY_RELEASE_CODE 20090128
-#define RUBY_PATCHLEVEL 100
+#define RUBY_RELEASE_CODE 20090129
+#define RUBY_PATCHLEVEL 101
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 7
#define RUBY_RELEASE_YEAR 2009
#define RUBY_RELEASE_MONTH 1
-#define RUBY_RELEASE_DAY 28
+#define RUBY_RELEASE_DAY 29
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];