Skip to content

Commit

Permalink
Refactor conversion of current time in project monitor page
Browse files Browse the repository at this point in the history
We've been fetching the 'DateTime' and afterwards did some string
replacement which made the produced string look (almost) identical[*]
to what 'Time.now.to_s' would produce.
Instead of doing all that we now just use 'Time.now'.

Time.now.to_s:                   "2018-10-30 13:25:52 +0000"
DateTime.now.to_s.sub('T', ' '): "2018-10-30 13:26:11+00:00"

The change itself was needed / demanded by Rubocop:
  https://github.com/rubocop-hq/ruby-style-guide#date--time
  • Loading branch information
bgeuken authored and dmarcoux committed Nov 5, 2018
1 parent a5ec667 commit 0b442dd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/api/app/views/webui/project/monitor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</tbody>
</table>
<% end -%>
<div id="refresh_date"><p>Updated at: <%= DateTime.now.to_s.sub(/T/, " ") %></p></div>
<div id="refresh_date"><p>Updated at: <%= Time.now %></p></div>
<div id="legend">
<h3>Legend</h3>
<ul>
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui/project/refresh_monitor.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ if( $("<%= id %>").innerHTML != "<%= st %>" ) {

<% end -%>
<%= update_element_function "refresh_date", :content => "Updated at: #{DateTime.now.to_s.sub(/T/,' ')}" -%>
<%= update_element_function "refresh_date", :content => "Updated at: #{Time.now}" -%>

0 comments on commit 0b442dd

Please sign in to comment.