aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorAbdelkader Boudih <terminale@gmail.com>2015-03-06 03:51:03 +0000
committerAbdelkader Boudih <terminale@gmail.com>2015-03-06 03:51:03 +0000
commit1c1bced7b17c9b0d2866f43bd2b35a1be16dbcf0 (patch)
tree3c4ee2f954cc46fc7cc0f147c58735574db6be8c /activesupport
parentcbac1fdf65286d7042ab263ce8a3af5d6022d3af (diff)
parent65183582884e316357b9bcf49b2e2b8bcc109451 (diff)
downloadrails-1c1bced7b17c9b0d2866f43bd2b35a1be16dbcf0.tar.gz
rails-1c1bced7b17c9b0d2866f43bd2b35a1be16dbcf0.tar.bz2
rails-1c1bced7b17c9b0d2866f43bd2b35a1be16dbcf0.zip
Merge pull request #19224 from davydovanton/doc-update-seconds-since-midnight
[ci skip] Update documentation for Time#seconds_since_midnight
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb
index 13610ba19f..6f1b653639 100644
--- a/activesupport/lib/active_support/core_ext/time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -48,7 +48,11 @@ class Time
alias_method :at, :at_with_coercion
end
- # Seconds since midnight: Time.now.seconds_since_midnight
+ # Returns the number of seconds since 00:00:00.
+ #
+ # Time.new(2012, 8, 29, 0, 0, 0).seconds_since_midnight # => 0
+ # Time.new(2012, 8, 29, 12, 34, 56).seconds_since_midnight # => 45296
+ # Time.new(2012, 8, 29, 23, 59, 59).seconds_since_midnight # => 86399
def seconds_since_midnight
to_i - change(:hour => 0).to_i + (usec / 1.0e+6)
end