Broken feed
1 min read
In the feed I had this check, the same for displaying posts:
last_updated = time_from_string(post[:datetime])
# Skip post if date is invalid or in the future
next if last_updated == nil || DateTime.now.to_time < last_updatedwhich worked properly for the site, but for the feed I was getting this error:
undefined method `w3cdtf' for class `ActiveSupport::TimeWithZone`which was happening when I was setting the item.updated field to last_updated. The fix was pretty easy (and obvious, now, after I fixed it) - just convert the returned object to_time:
def time_from_string(string)
[...]
DateTime.new(date_matches[1].to_i, date_matches[2].to_i, date_matches[3].to_i, time[:hour], time[:min], 0, time[:zone]).in_time_zone.to_time
end