Module: FeedNormalizer::TimeFix
Instance Method Summary collapse
-
#reparse(obj) ⇒ Object
Reparse any Time instances, due to RSS::Parser’s redefinition of certain aspects of the Time class that creates unexpected behaviour when extending the Time class, as some common third party libraries do.
Instance Method Details
#reparse(obj) ⇒ Object
Reparse any Time instances, due to RSS::Parser’s redefinition of certain aspects of the Time class that creates unexpected behaviour when extending the Time class, as some common third party libraries do. See code.google.com/p/feed-normalizer/issues/detail?id=13.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/structures.rb', line 125 def reparse(obj) @parsed ||= false if obj.is_a?(String) @parsed = true begin Time.at(obj) rescue Time.rfc2822(obj) rescue Time.parse(obj) rescue @parsed = false obj end else return obj if @parsed if obj.is_a?(Time) @parsed = true Time.at(obj) rescue obj end end end |