From ca02d69e8b79af99ce6fc85ca62ac51ba774ccc8 Mon Sep 17 00:00:00 2001 From: davidgisbey Date: Mon, 16 Oct 2023 17:38:28 +0100 Subject: [PATCH] Use Time.zone.parse in ManualUpdatesPresenter At the moment, it uses Date.parse which doesn't account for the difference in timing between the timestamp (UTC) and local time (BST). This causes issues with some updates being a day off if they were published between 00.00 & 00.59. Time.zone.parse parses the date correctly into the "London" timezone. We still need to convert it back into a date though as it groups on year, then by identical dates, so all updates for a day are grouped. --- app/presenters/content_item/manual_updates.rb | 2 +- test/presenters/content_item/manual_updates_test.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/presenters/content_item/manual_updates.rb b/app/presenters/content_item/manual_updates.rb index bbd959ba6..4605a3905 100644 --- a/app/presenters/content_item/manual_updates.rb +++ b/app/presenters/content_item/manual_updates.rb @@ -28,7 +28,7 @@ def change_notes end def updated_at(published_at) - Date.parse(published_at) + Time.zone.parse(published_at).to_date end def group_updates_by_year(updates) diff --git a/test/presenters/content_item/manual_updates_test.rb b/test/presenters/content_item/manual_updates_test.rb index 1f405e8a2..e4f908d3f 100644 --- a/test/presenters/content_item/manual_updates_test.rb +++ b/test/presenters/content_item/manual_updates_test.rb @@ -22,7 +22,7 @@ def initialize "base_path" => "/guidance/content-design/content-policy", "title" => "Content policy", "change_note" => "New section added.", - "published_at" => "2014-10-06T23:49:25Z", + "published_at" => "2014-10-06T22:49:25Z", }, { "base_path" => "/guidance/content-design/user-needs", @@ -34,7 +34,7 @@ def initialize "base_path" => "/guidance/content-design/random-section", "title" => "Random section", "change_note" => "New section added.", - "published_at" => "2013-11-06T10:49:25Z", + "published_at" => "2013-09-06T23:49:25Z", }, ], }, @@ -88,7 +88,7 @@ def initialize 2013, [ [ - "6 November 2013 #{I18n.t('manuals.updates_amendments')}", + "7 September 2013 #{I18n.t('manuals.updates_amendments')}", { (fourth_note["base_path"]).to_s => [fourth_note], },