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

Add useful diff representation of Time-like values #61

Merged
merged 2 commits into from
Nov 26, 2019

Conversation

Mange
Copy link
Contributor

@Mange Mange commented Nov 20, 2019

This should add a more useful diff for Time instances, as well as make the diff output from ActiveSupport::TimeWithZone instances readable.

Previously the ActiveSupport::TimeWithZone diff output would contain all the timezones, leading to several thousand lines in the diff. Now all time-like instances will work the same way: Single-line diffs will be of a simple ISO-like string, while the full diff will show which parts of the time actually differs.

Timezone is promptly shown, both with name and with GMT offset.

This should fix #52.

Screenshots

Before

Time vs Time

Screenshot 2019-11-20 15:08:01

Time vs ActiveSupport::TimeWithZone

Screenshot 2019-11-20 15:08:44

After

Time vs Time

Screenshot 2019-11-20 15:07:02

Time vs ActiveSupport::TimeWithZone

Screenshot 2019-11-20 15:08:52

This should add a more useful diff for Time instances, as well as make
the diff output from ActiveSupport::TimeWithZone instances readable.

Previously the ActiveSupport::TimeWithZone diff output would contain all
the timezones, leading to several thousand lines in the diff. Now all
time-like instances will work the same way: Single-line diffs will be of
a simple ISO-like string, while the full diff will show which parts of
the time actually differs.

Timezone is promptly shown, both with name and with GMT offset.
This should help some people even more quickly see why the two dates are
different moments in time as they won't have to do the offset
calculation in their heads when they see the difference in hours/minutes
and gmt_offset.
@Mange
Copy link
Contributor Author

Mange commented Nov 20, 2019

I added an additional commit that shows a normalized timestamp (in UTC) in the diff if the two dates have different timezones set.

Screenshot 2019-11-20 15:18:38

I hope this would help people that struggle with timezones. Let me know what you think about that one.

@mcmire
Copy link
Collaborator

mcmire commented Nov 26, 2019

Hey, sorry for the delay in responding, I just switched over to the new notifications so I guess this one slipped through. Thanks so much for fixing this — looks like you figured out how things work :) Your PR description was really easy to follow and your implementation looks great too! I think this will be really useful.

@mcmire mcmire added this to the v0.3.0 milestone Nov 26, 2019
@mcmire mcmire merged commit e57b6f8 into splitwise:master Nov 26, 2019
@Mange
Copy link
Contributor Author

Mange commented Nov 26, 2019

Thanks a lot! 😄

@Mange Mange deleted the time-with-zone-inspection branch November 26, 2019 07:21
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.

Add object inspection for ActiveSupport::TimeZone
2 participants