---
title: "Broken feed"
slug: broken-feed
section: tech
date: 2015-06-03T11:06:00.000Z
canonical: https://roland.leth.ro/blog/tech/broken-feed
---

In the feed I had this check, the same for displaying posts:

```ruby
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_updated
```
which worked properly for the site, but for the feed I was getting this error:

```ruby
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`:

```ruby
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
```