Skip to content

Commit

Permalink
Use Time.zone.parse in ManualUpdatesPresenter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
davidgisbey committed Oct 18, 2023
1 parent 9c30d45 commit ca02d69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/presenters/content_item/manual_updates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions test/presenters/content_item/manual_updates_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
},
],
},
Expand Down Expand Up @@ -88,7 +88,7 @@ def initialize
2013,
[
[
"6 November 2013 <span class=\"govuk-visually-hidden\">#{I18n.t('manuals.updates_amendments')}</span>",
"7 September 2013 <span class=\"govuk-visually-hidden\">#{I18n.t('manuals.updates_amendments')}</span>",
{
(fourth_note["base_path"]).to_s => [fourth_note],
},
Expand Down

0 comments on commit ca02d69

Please sign in to comment.