diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/time/calculations.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/time/calculations.rb | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb index 34d4d88bd3..9146d82bd8 100644 --- a/activesupport/lib/active_support/core_ext/time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/time/calculations.rb @@ -217,7 +217,7 @@ class Time # Returns a new Time representing the end of the day, 23:59:59.999999 (.999999999 in ruby1.9) def end_of_day - change(:hour => 23, :min => 59, :sec => 59, :usec => 999999.999) + change(:hour => 23, :min => 59, :sec => 59, :usec => Rational(999999999, 1000)) end # Returns a new Time representing the start of the hour (x:00) @@ -228,11 +228,7 @@ class Time # Returns a new Time representing the end of the hour, x:59:59.999999 (.999999999 in ruby1.9) def end_of_hour - change( - :min => 59, - :sec => 59, - :usec => 999999.999 - ) + change(:min => 59, :sec => 59, :usec => Rational(999999999, 1000)) end # Returns a new Time representing the start of the month (1st of the month, 0:00) @@ -246,7 +242,7 @@ class Time def end_of_month #self - ((self.mday-1).days + self.seconds_since_midnight) last_day = ::Time.days_in_month(month, year) - change(:day => last_day, :hour => 23, :min => 59, :sec => 59, :usec => 999999.999) + change(:day => last_day, :hour => 23, :min => 59, :sec => 59, :usec => Rational(999999999, 1000)) end alias :at_end_of_month :end_of_month @@ -270,7 +266,7 @@ class Time # Returns a new Time representing the end of the year (end of the 31st of december) def end_of_year - change(:month => 12, :day => 31, :hour => 23, :min => 59, :sec => 59, :usec => 999999.999) + change(:month => 12, :day => 31, :hour => 23, :min => 59, :sec => 59, :usec => Rational(999999999, 1000)) end alias :at_end_of_year :end_of_year |