Skip to content

Commit

Permalink
Let #to_iso8601_date convert to UTC first
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdefreyne committed Oct 22, 2016
1 parent f35d877 commit 9df5b15
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/nanoc/extra/core_ext/time.rb
Expand Up @@ -2,7 +2,7 @@
module Nanoc::Extra::TimeExtensions
# @return [String] The time in an ISO-8601 date format.
def __nanoc_to_iso8601_date
strftime('%Y-%m-%d')
getutc.strftime('%Y-%m-%d')
end

# @return [String] The time in an ISO-8601 time format.
Expand Down
6 changes: 5 additions & 1 deletion test/extra/core_ext/test_time.rb
@@ -1,8 +1,12 @@
class Nanoc::ExtraCoreExtTimeTest < Nanoc::TestCase
def test___nanoc_to_iso8601_date
def test___nanoc_to_iso8601_date_utc
assert_equal('2008-05-19', Time.utc(2008, 5, 19, 14, 20, 0, 0).__nanoc_to_iso8601_date)
end

def test___nanoc_to_iso8601_date_non_utc
assert_equal('2008-05-18', Time.new(2008, 5, 19, 0, 0, 0, '+02:00').__nanoc_to_iso8601_date)
end

def test___nanoc_to_iso8601_time
assert_equal('2008-05-19T14:20:00Z', Time.utc(2008, 5, 19, 14, 20, 0, 0).__nanoc_to_iso8601_time)
end
Expand Down
6 changes: 3 additions & 3 deletions test/helpers/test_xml_sitemap.rb
Expand Up @@ -30,7 +30,7 @@ def test_xml_sitemap
@items << item

# Create item 3
attrs = { mtime: Time.parse('2004-07-12'), changefreq: 'daily', priority: 0.5 }
attrs = { mtime: Time.parse('2004-07-12 00:00:00 +02:00'), changefreq: 'daily', priority: 0.5 }
item = Nanoc::ItemWithRepsView.new(Nanoc::Int::Item.new('some content 3', attrs, '/item-three/'), @view_context)
@items << item
create_item_rep(item.unwrap, :three_a, '/item-three/a/')
Expand Down Expand Up @@ -70,8 +70,8 @@ def test_xml_sitemap
assert_equal '0.5', urls[3].css('> priority').inner_text
assert_equal '', urls[0].css('> lastmod').inner_text
assert_equal '', urls[1].css('> lastmod').inner_text
assert_equal '2004-07-12', urls[2].css('> lastmod').inner_text
assert_equal '2004-07-12', urls[3].css('> lastmod').inner_text
assert_equal '2004-07-11', urls[2].css('> lastmod').inner_text
assert_equal '2004-07-11', urls[3].css('> lastmod').inner_text
end
end

Expand Down

0 comments on commit 9df5b15

Please sign in to comment.