lib/xml-sitemap.rb in xml-sitemap-1.0.3 vs lib/xml-sitemap.rb in xml-sitemap-1.0.4
- old
+ new
@@ -1,5 +1,7 @@
+require 'time'
+
module XmlSitemap
PERIODS = [:none, :always, :hourly, :daily, :weekly, :monthly, :yearly, :never]
class Item
attr_reader :path
@@ -52,11 +54,11 @@
output << '<?xml version="1.0" encoding="UTF-8"?>'
output << '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
@items.each do |item|
output << '<url>'
output << "<loc>http://#{@domain}#{item.path.to_s}</loc>"
- output << "<lastmod>#{item.updated.utc.strftime("%Y-%m-%dT%H:%M:%S-0000")}</lastmod>"
+ output << "<lastmod>#{item.updated.utc.iso8601}</lastmod>"
output << "<changefreq>#{item.changefreq.to_s}</changefreq>"
output << "<priority>#{item.priority.to_s}</priority>"
output << '</url>'
end
output << '</urlset>'
@@ -73,11 +75,11 @@
end
# Add XmlSitemap::Map item to sitemap index
def add(map)
raise 'XmlSitemap::Map object requred!' unless map.kind_of?(Map)
- @maps << {:loc => "http://#{@domain}/#{map.index_path}", :lastmod => map.created_at.for_sitemap}
+ @maps << {:loc => "http://#{@domain}/#{map.index_path}", :lastmod => map.created_at.utc.iso8601}
end
# Generate sitemap XML index
def render
output = [] ; map_id = 1
@@ -91,10 +93,6 @@
end
output << '</sitemapindex>'
return output.join("\n")
end
end
-end
-
-class Time
- def for_sitemap ; self.utc.strftime("%Y-%m-%dT%H:%M:%S-0000") ; end
end
\ No newline at end of file