From 13bdef74b3c759e25d66ac54d6e4eee40b5c4211 Mon Sep 17 00:00:00 2001 From: Jyri-Petteri Paloposki Date: Sun, 29 Jun 2025 13:25:14 +0300 Subject: [PATCH] Update the date formatting syntax --- app/views/contexts/index.rss.builder | 2 +- app/views/todos/index.rss.builder | 2 +- test/controllers/contexts_controller_test.rb | 2 +- test/controllers/projects_controller_test.rb | 2 +- test/controllers/todos_controller_test.rb | 4 ++-- test/fixtures/contexts.yml | 2 +- test/fixtures/notes.yml | 6 +++--- test/fixtures/projects.yml | 6 +++--- test/fixtures/recurring_todos.yml | 12 ++++++------ test/fixtures/tags.yml | 2 +- test/fixtures/todos.yml | 12 ++++++------ test/models/recurring_todo_test.rb | 2 +- .../abstract_recurrence_pattern_test.rb | 16 ++++++++-------- test/models/todo_test.rb | 2 +- 14 files changed, 36 insertions(+), 36 deletions(-) diff --git a/app/views/contexts/index.rss.builder b/app/views/contexts/index.rss.builder index 5459d1f1..ee98e19f 100644 --- a/app/views/contexts/index.rss.builder +++ b/app/views/contexts/index.rss.builder @@ -11,7 +11,7 @@ xml.rss :version => "2.0" do xml.item do xml.title h(context.title) xml.description context_summary(context, count_undone_todos_phrase(context)) - xml.pubDate context.created_at.to_s(:rfc822) + xml.pubDate context.created_at.to_formatted_s(:rfc822) xml.link context_url(context) xml.guid context_url(context) end diff --git a/app/views/todos/index.rss.builder b/app/views/todos/index.rss.builder index 7e36907c..ca149d09 100644 --- a/app/views/todos/index.rss.builder +++ b/app/views/todos/index.rss.builder @@ -11,7 +11,7 @@ xml.rss :version => "2.0" do xml.item do xml.title h(todo.description) xml.description feed_content_for_todo(todo) - xml.pubDate todo.created_at.to_s(:rfc822) + xml.pubDate todo.created_at.to_formatted_s(:rfc822) xml.link (todo.project && !todo.project.is_a?(NullProject)) ? project_url(todo.project) : context_url(todo.context) xml.guid todo_url(todo) end diff --git a/test/controllers/contexts_controller_test.rb b/test/controllers/contexts_controller_test.rb index f1660f95..580fa4a5 100644 --- a/test/controllers/contexts_controller_test.rb +++ b/test/controllers/contexts_controller_test.rb @@ -124,7 +124,7 @@ class ContextsControllerTest < ActionController::TestCase %w(guid link).each do |node| assert_select node, /http:\/\/test.host\/contexts\/.+/ end - assert_select 'pubDate', contexts(:agenda).created_at.to_s(:rfc822) + assert_select 'pubDate', contexts(:agenda).created_at.to_formatted_s(:rfc822) end end end diff --git a/test/controllers/projects_controller_test.rb b/test/controllers/projects_controller_test.rb index 4666dddd..e58e62d8 100644 --- a/test/controllers/projects_controller_test.rb +++ b/test/controllers/projects_controller_test.rb @@ -102,7 +102,7 @@ class ProjectsControllerTest < ActionController::TestCase %w(guid link).each do |node| assert_select node, /http:\/\/test.host\/projects\/.+/ end - assert_select 'pubDate', projects(:timemachine).updated_at.to_s(:rfc822) + assert_select 'pubDate', projects(:timemachine).updated_at.to_formatted_s(:rfc822) end end end diff --git a/test/controllers/todos_controller_test.rb b/test/controllers/todos_controller_test.rb index 806a2cf2..99ffb70f 100644 --- a/test/controllers/todos_controller_test.rb +++ b/test/controllers/todos_controller_test.rb @@ -403,7 +403,7 @@ class TodosControllerTest < ActionController::TestCase assert_equal "bar, foo", t.tag_list expected = Date.new(2006,11,30) actual = t.due.to_date - assert_equal expected, actual, "Expected #{expected.to_s(:db)}, was #{actual.to_s(:db)}" + assert_equal expected, actual, "Expected #{expected.to_formatted_s(:db)}, was #{actual.to_formatted_s(:db)}" end def test_update_todos_with_blank_project_name @@ -551,7 +551,7 @@ class TodosControllerTest < ActionController::TestCase assert_select 'description', /.*/ assert_select 'link', %r{http://test.host/contexts/.+} assert_select 'guid', %r{http://test.host/todos/.+} - assert_select 'pubDate', todos(:call_bill_gates_every_day).created_at.to_s(:rfc822) + assert_select 'pubDate', todos(:call_bill_gates_every_day).created_at.to_formatted_s(:rfc822) end end end diff --git a/test/fixtures/contexts.yml b/test/fixtures/contexts.yml index 4d2e0dc0..15af746d 100644 --- a/test/fixtures/contexts.yml +++ b/test/fixtures/contexts.yml @@ -5,7 +5,7 @@ <% def today - Time.zone.now.utc.to_s(:db) + Time.zone.now.utc.to_formatted_s(:db) end %> diff --git a/test/fixtures/notes.yml b/test/fixtures/notes.yml index 13b8492d..24c34eb3 100644 --- a/test/fixtures/notes.yml +++ b/test/fixtures/notes.yml @@ -4,15 +4,15 @@ # rails does automatically in models or controllers! Convert to utc manually! <% def today - Time.zone.now.utc.to_s(:db) + Time.zone.now.utc.to_formatted_s(:db) end def next_week - 1.week.from_now.utc.to_s(:db) + 1.week.from_now.utc.to_formatted_s(:db) end def last_week - 1.week.ago.utc.to_s(:db) + 1.week.ago.utc.to_formatted_s(:db) end %> diff --git a/test/fixtures/projects.yml b/test/fixtures/projects.yml index c69f6230..11375ec7 100644 --- a/test/fixtures/projects.yml +++ b/test/fixtures/projects.yml @@ -4,13 +4,13 @@ # rails does automatically in models or controllers! Convert to utc manually! <% def today - Time.zone.now.utc.beginning_of_day.to_s(:db) + Time.zone.now.utc.beginning_of_day.to_formatted_s(:db) end def yesterday - 1.day.ago.utc.beginning_of_day.to_s(:db) + 1.day.ago.utc.beginning_of_day.to_formatted_s(:db) end def last_week - 1.week.ago.utc.beginning_of_day.to_s(:db) + 1.week.ago.utc.beginning_of_day.to_formatted_s(:db) end %> diff --git a/test/fixtures/recurring_todos.yml b/test/fixtures/recurring_todos.yml index 2c2a6143..5c7a0ae4 100644 --- a/test/fixtures/recurring_todos.yml +++ b/test/fixtures/recurring_todos.yml @@ -3,27 +3,27 @@ <% def today - Time.zone.now.utc.beginning_of_day.to_s(:db) + Time.zone.now.utc.beginning_of_day.to_formatted_s(:db) end def next_week - 1.week.from_now.utc.beginning_of_day.to_s(:db) + 1.week.from_now.utc.beginning_of_day.to_formatted_s(:db) end def last_week - 1.week.ago.utc.beginning_of_day.to_s(:db) + 1.week.ago.utc.beginning_of_day.to_formatted_s(:db) end def two_weeks_ago - 2.weeks.ago.utc.beginning_of_day.to_s(:db) + 2.weeks.ago.utc.beginning_of_day.to_formatted_s(:db) end def two_weeks_hence - 2.weeks.from_now.utc.beginning_of_day.to_s(:db) + 2.weeks.from_now.utc.beginning_of_day.to_formatted_s(:db) end def way_back - Time.zone.local(2008,1,1).utc.to_s(:db) + Time.zone.local(2008,1,1).utc.to_formatted_s(:db) end %> diff --git a/test/fixtures/tags.yml b/test/fixtures/tags.yml index c746e7f3..8cdef82e 100644 --- a/test/fixtures/tags.yml +++ b/test/fixtures/tags.yml @@ -3,7 +3,7 @@ <% def today - Time.zone.now.utc.beginning_of_day.to_s(:db) + Time.zone.now.utc.beginning_of_day.to_formatted_s(:db) end %> diff --git a/test/fixtures/todos.yml b/test/fixtures/todos.yml index 8d810c68..16485d14 100644 --- a/test/fixtures/todos.yml +++ b/test/fixtures/todos.yml @@ -8,27 +8,27 @@ def yesterday Time.zone.now.utc.beginning_of_day - 1.day end def today - Time.zone.now.utc.beginning_of_day.to_s(:db) + Time.zone.now.utc.beginning_of_day.to_formatted_s(:db) end def tomorrow - (Time.zone.now.utc.beginning_of_day + 1.day).to_s(:db) + (Time.zone.now.utc.beginning_of_day + 1.day).to_formatted_s(:db) end def next_week - 1.week.from_now.utc.beginning_of_day.to_s(:db) + 1.week.from_now.utc.beginning_of_day.to_formatted_s(:db) end def last_week - 1.week.ago.utc.beginning_of_day.to_s(:db) + 1.week.ago.utc.beginning_of_day.to_formatted_s(:db) end def two_weeks_ago - 2.weeks.ago.utc.beginning_of_day.to_s(:db) + 2.weeks.ago.utc.beginning_of_day.to_formatted_s(:db) end def two_weeks_hence - 2.weeks.from_now.utc.beginning_of_day.to_s(:db) + 2.weeks.from_now.utc.beginning_of_day.to_formatted_s(:db) end %> diff --git a/test/models/recurring_todo_test.rb b/test/models/recurring_todo_test.rb index 7779307e..dae4783e 100644 --- a/test/models/recurring_todo_test.rb +++ b/test/models/recurring_todo_test.rb @@ -110,7 +110,7 @@ class RecurringTodoTest < ActiveSupport::TestCase # every_day should return start_day if it is in the future @every_day.start_from = @in_three_days due_date = @every_day.get_due_date(nil) - assert_equal @in_three_days.at_midnight.to_s(:db), due_date.to_s(:db) + assert_equal @in_three_days.at_midnight.to_formatted_s(:db), due_date.to_formatted_s(:db) due_date = @every_day.get_due_date(@tomorrow) assert_equal @in_three_days.at_midnight, due_date diff --git a/test/models/recurring_todos/abstract_recurrence_pattern_test.rb b/test/models/recurring_todos/abstract_recurrence_pattern_test.rb index b5d13e3c..74cfc3fc 100644 --- a/test/models/recurring_todos/abstract_recurrence_pattern_test.rb +++ b/test/models/recurring_todos/abstract_recurrence_pattern_test.rb @@ -122,8 +122,8 @@ module RecurringTodos travel_to Time.zone.local(2013,1,1) do rt = create_recurring_todo assert_equal Time.zone.parse("2013-01-01 00:00:00"), rt.send(:determine_start, nil), "no previous date, use today" - assert_equal Time.zone.parse("2013-01-01 00:00:00"), rt.send(:determine_start, nil, 1.day).to_s(:db), "no previous date, use today without offset" - assert_equal Time.zone.parse("2013-01-02 00:00:00"), rt.send(:determine_start, Time.zone.now, 1.day).to_s(:db), "use previous date and offset" + assert_equal Time.zone.parse("2013-01-01 00:00:00"), rt.send(:determine_start, nil, 1.day).to_formatted_s(:db), "no previous date, use today without offset" + assert_equal Time.zone.parse("2013-01-02 00:00:00"), rt.send(:determine_start, Time.zone.now, 1.day).to_formatted_s(:db), "use previous date and offset" end end @@ -131,14 +131,14 @@ module RecurringTodos rt = create_recurring_todo # march 2014 has 5 saturdays, the last will return the 5th - assert_equal Time.zone.parse("2014-03-01 00:00:00"), rt.send(:get_xth_day_of_month, 1, 6, 3, 2014).to_s(:db) - assert_equal Time.zone.parse("2014-03-22 00:00:00"), rt.send(:get_xth_day_of_month, 4, 6, 3, 2014).to_s(:db) - assert_equal Time.zone.parse("2014-03-29 00:00:00"), rt.send(:get_xth_day_of_month, 5, 6, 3, 2014).to_s(:db) + assert_equal Time.zone.parse("2014-03-01 00:00:00"), rt.send(:get_xth_day_of_month, 1, 6, 3, 2014).to_formatted_s(:db) + assert_equal Time.zone.parse("2014-03-22 00:00:00"), rt.send(:get_xth_day_of_month, 4, 6, 3, 2014).to_formatted_s(:db) + assert_equal Time.zone.parse("2014-03-29 00:00:00"), rt.send(:get_xth_day_of_month, 5, 6, 3, 2014).to_formatted_s(:db) # march 2014 has 4 fridays, the last will return the 4th - assert_equal Time.zone.parse("2014-03-07 00:00:00"), rt.send(:get_xth_day_of_month, 1, 5, 3, 2014).to_s(:db) - assert_equal Time.zone.parse("2014-03-28 00:00:00"), rt.send(:get_xth_day_of_month, 4, 5, 3, 2014).to_s(:db) - assert_equal Time.zone.parse("2014-03-28 00:00:00"), rt.send(:get_xth_day_of_month, 5, 5, 3, 2014).to_s(:db) + assert_equal Time.zone.parse("2014-03-07 00:00:00"), rt.send(:get_xth_day_of_month, 1, 5, 3, 2014).to_formatted_s(:db) + assert_equal Time.zone.parse("2014-03-28 00:00:00"), rt.send(:get_xth_day_of_month, 4, 5, 3, 2014).to_formatted_s(:db) + assert_equal Time.zone.parse("2014-03-28 00:00:00"), rt.send(:get_xth_day_of_month, 5, 5, 3, 2014).to_formatted_s(:db) assert_raise(RuntimeError, "should check on valid weekdays"){ rt.send(:get_xth_day_of_month, 5, 9, 3, 2014) } assert_raise(RuntimeError, "should check on valid count x"){ rt.send(:get_xth_day_of_month, 6, 5, 3, 2014) } diff --git a/test/models/todo_test.rb b/test/models/todo_test.rb index dd1e084b..e189b7ce 100644 --- a/test/models/todo_test.rb +++ b/test/models/todo_test.rb @@ -10,7 +10,7 @@ class TodoTest < ActiveSupport::TestCase end def next_week - 1.week.from_now.beginning_of_day.to_s(:db) + 1.week.from_now.beginning_of_day.to_formatted_s(:db) end # Test loading a todo item