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

Render Local Time #5190

Merged
merged 3 commits into from
Sep 23, 2023
Merged

Render Local Time #5190

merged 3 commits into from
Sep 23, 2023

Conversation

SajjadAhmad14
Copy link
Collaborator

What github issue is this PR for, if any?

Resolves #5134

What changed, and why?

We created a new view component named LocalTimeComponent. This component renders user local time.

How is this tested? (please write tests!) 💖💪

Component is tested with both positive and negative tests.

@FireLemons
Copy link
Collaborator

Can you add this to a random view in your local app without committing and take a screenshot?

browser_tz = ActiveSupport::TimeZone.find_tzinfo(cookies[:browser_time_zone])
ActiveSupport::TimeZone.all.find { |zone| zone.tzinfo == browser_tz } || Time.zone
rescue TZInfo::UnknownTimezone, TZInfo::InvalidTimezoneIdentifier
@time_zone = Time.zone
Copy link
Collaborator

Choose a reason for hiding this comment

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

we need this from the client. Can you add this as a parameter for the component?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @FireLemons, this is the local time zone of the user taken from browser. The arguments required for the component and mentioned in the issue are the time in unix timestamp format, and the format. So do I need to pass the time zone as the third argument?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, it's from the client

@SajjadAhmad14
Copy link
Collaborator Author

Can you add this to a random view in your local app without committing and take a screenshot?
time

<%= render (LocalTimeComponent.new(format: 12, unix_timestamp: 1694349775))%>
I rendered this component in users/edit_profile.rb

@FireLemons
Copy link
Collaborator

Oh my bad. I didn't know Time.zone was from the client. 🥇

@FireLemons FireLemons merged commit 470c61c into main Sep 23, 2023
@FireLemons FireLemons deleted the local-time branch September 23, 2023 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
erb ruby Pull requests that update Ruby code Tests! 🎉💖👏
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Local Time Display Component
2 participants