ruby-changes:10321
From: shyouhei <ko1@a...>
Date: Thu, 29 Jan 2009 11:53:51 +0900 (JST)
Subject: [ruby-changes:10321] Ruby:r21864 (ruby_1_8_6): merge revision(s) 19707:
shyouhei 2009-01-29 11:53:30 +0900 (Thu, 29 Jan 2009) New Revision: 21864 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21864 Log: merge revision(s) 19707: * lib/date.rb (today,now): should produce own instances. [ruby-talk:317020] Modified files: branches/ruby_1_8_6/ChangeLog branches/ruby_1_8_6/lib/date.rb branches/ruby_1_8_6/version.h Index: ruby_1_8_6/ChangeLog =================================================================== --- ruby_1_8_6/ChangeLog (revision 21863) +++ ruby_1_8_6/ChangeLog (revision 21864) @@ -1,3 +1,8 @@ +Thu Jan 29 11:53:14 2009 Tadayoshi Funaba <tadf@d...> + + * lib/date.rb (today,now): should produce own instances. + [ruby-talk:317020] + Wed Jan 28 22:48:00 2009 Nobuyoshi Nakada <nobu@r...> * eval.c (rb_mod_modfunc): method undefined in included module Index: ruby_1_8_6/version.h =================================================================== --- ruby_1_8_6/version.h (revision 21863) +++ ruby_1_8_6/version.h (revision 21864) @@ -1,15 +1,15 @@ #define RUBY_VERSION "1.8.6" -#define RUBY_RELEASE_DATE "2009-01-28" +#define RUBY_RELEASE_DATE "2009-01-29" #define RUBY_VERSION_CODE 186 -#define RUBY_RELEASE_CODE 20090128 -#define RUBY_PATCHLEVEL 314 +#define RUBY_RELEASE_CODE 20090129 +#define RUBY_PATCHLEVEL 315 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_TEENY 6 #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[]; Index: ruby_1_8_6/lib/date.rb =================================================================== --- ruby_1_8_6/lib/date.rb (revision 21863) +++ ruby_1_8_6/lib/date.rb (revision 21864) @@ -1619,12 +1619,23 @@ # 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/