Get a string for a date and return a time object options[:format]: String representation (default “%d/%m/%Y”) options[:time_offset]: Offset to apply to parsed time TODO: This should be removed in favor of I18n.parse_date
currently ubiquo filter functionality rely on this method.
# File vendor/plugins/ubiquo_core/lib/ubiquo/extensions/date_parser.rb, line 9
9: def parse_date(string_date, options = {})
10: return if string_date.blank?
11: return string_date if string_date.instance_of?(Time)
12: return string_date if string_date.instance_of?(ActiveSupport::TimeWithZone)
13:
14: format = options.delete(:format) || "%d/%m/%Y"
15: time_offset = options.delete(:time_offset)
16: begin
17: time = Date.strptime(string_date, format)
18: rescue ArgumentError, TypeError
19: return
20: end
21: time += time_offset if time_offset
22: time
23: end
Disabled; run with $DEBUG to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.