ruby-changes:10322
From: shyouhei <ko1@a...>
Date: Thu, 29 Jan 2009 11:54:50 +0900 (JST)
Subject: [ruby-changes:10322] Ruby:r21866 (ruby_1_8_7): merge revision(s) 19707:
shyouhei 2009-01-29 11:54:38 +0900 (Thu, 29 Jan 2009) New Revision: 21866 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21866 Log: merge revision(s) 19707: * lib/date.rb (today,now): should produce own instances. [ruby-talk:317020] Modified files: branches/ruby_1_8_7/ChangeLog branches/ruby_1_8_7/lib/date.rb branches/ruby_1_8_7/version.h Index: ruby_1_8_7/ChangeLog =================================================================== --- ruby_1_8_7/ChangeLog (revision 21865) +++ ruby_1_8_7/ChangeLog (revision 21866) @@ -1,3 +1,8 @@ +Thu Jan 29 11:54:22 2009 Tadayoshi Funaba <tadf@d...> + + * lib/date.rb (today,now): should produce own instances. + [ruby-talk:317020] + Wed Jan 28 22:51:55 2009 Nobuyoshi Nakada <nobu@r...> * eval.c (rb_mod_modfunc): method undefined in included module Index: ruby_1_8_7/version.h =================================================================== --- ruby_1_8_7/version.h (revision 21865) +++ ruby_1_8_7/version.h (revision 21866) @@ -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[]; Index: ruby_1_8_7/lib/date.rb =================================================================== --- ruby_1_8_7/lib/date.rb (revision 21865) +++ ruby_1_8_7/lib/date.rb (revision 21866) @@ -1660,12 +1660,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/