Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust time format in maintenance listing table to include year #364

Merged
merged 4 commits into from
Mar 12, 2021

Conversation

samudary
Copy link
Contributor

@samudary samudary commented Feb 23, 2021

Fixes #363

Rails only includes the following time format options: https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/en-US.yml#L211-L214

To make the timestamp displayed for the last vacuum or analyze less ambiguous I decided to add a year. I provided a custom format string to maintain the existing "day short_month ... 24-hour clock time" format instead of using :long which would completely change the order.

Example:

# Old
I18n.l 3.years.ago.in_time_zone("UTC"), format: :short
=> "23 Feb 23:57"

# New
I18n.l 3.years.ago.in_time_zone("UTC"), format: "%d %b %Y %H:%M"
=> "23 Feb 2018 23:57"

@ankane
Copy link
Owner

ankane commented Mar 12, 2021

Hey @samudary, thanks for the PR! Agree it be better to make it less ambiguous. What do you think of showing the relative time in the table (like "5 months ago"), with full time in a title attribute so it shows up on hover?

@samudary
Copy link
Contributor Author

@ankane I like that! Pushed another commit with that change.

Example:

Screen Shot 2021-03-12 at 10 18 18 AM

Copy link
Owner

@ankane ankane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, looks great. Left two minor comments inline.

@@ -26,5 +26,15 @@ def pghero_remove_index(query)
ret << ", column: #{columns.inspect}" if columns
ret
end

def formatted_vacuum_times(time)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's prefix helpers with pghero_ since I think these will be global.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! Updated

end

def formatted_date_time(time)
l time.in_time_zone(@time_zone), format: "%d %b %Y %H:%M"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we can probably use :long since it no longer needs to fit into the table cell.

@ankane ankane merged commit b87a064 into ankane:master Mar 12, 2021
@ankane
Copy link
Owner

ankane commented Mar 12, 2021

Thanks @samudary!

This was referenced Mar 15, 2021
elguapo1611 pushed a commit to instacart/pghero that referenced this pull request Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Time format in maintenance listing table is ambiguous
2 participants