diff options
author | claudiob <claudiob@gmail.com> | 2014-12-04 22:27:49 -0800 |
---|---|---|
committer | claudiob <claudiob@gmail.com> | 2014-12-04 22:27:49 -0800 |
commit | d4fd3a18bd02480dd69d62e700fec8806942f45a (patch) | |
tree | 710c4775243923a3faf06af1146c64267e9bd1d1 /activesupport/lib/active_support | |
parent | d61341a30463057a52a755dd62c0e475354c0513 (diff) | |
download | rails-d4fd3a18bd02480dd69d62e700fec8806942f45a.tar.gz rails-d4fd3a18bd02480dd69d62e700fec8806942f45a.tar.bz2 rails-d4fd3a18bd02480dd69d62e700fec8806942f45a.zip |
Better doc for AS::DateTime#seconds_since_midnight
Adds examples and keeps coherent with the documentation of the
similar method `seconds_until_end_of_day`. [ci skip]
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/date_time/calculations.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb index dc4e767e9d..55ad384f4f 100644 --- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb +++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb @@ -10,7 +10,11 @@ class DateTime end end - # Seconds since midnight: DateTime.now.seconds_since_midnight. + # Returns the number of seconds since 00:00:00. + # + # DateTime.new(2012, 8, 29, 0, 0, 0).seconds_since_midnight # => 0 + # DateTime.new(2012, 8, 29, 12, 34, 56).seconds_since_midnight # => 45296 + # DateTime.new(2012, 8, 29, 23, 59, 59).seconds_since_midnight # => 86399 def seconds_since_midnight sec + (min * 60) + (hour * 3600) end |