Getting times in different convenient string representations and other objects
Methods
Public Class methods
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/time/conversions.rb, line 8
8: def self.append_features(klass)
9: super
10: klass.send(:alias_method, :to_default_s, :to_s)
11: klass.send(:alias_method, :to_s, :to_formatted_s)
12: end
Public Instance methods
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/time/conversions.rb, line 23
23: def to_date
24: ::Date.new(year, month, day)
25: end
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/time/conversions.rb, line 14
14: def to_formatted_s(format = :default)
15: case format
16: when :default then to_default_s
17: when :db then strftime("%Y-%m-%d %H:%M:%S")
18: when :short then strftime("%e %b %H:%M").strip
19: when :long then strftime("%B %e, %Y %H:%M").strip
20: end
21: end
To be able to keep Dates and Times interchangeable on conversions
[ show source ]
# File vendor/rails/activesupport/lib/active_support/core_ext/time/conversions.rb, line 28
28: def to_time
29: self
30: end