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

Support for humanizing DateTimeOffset #399

Merged
merged 4 commits into from
Mar 28, 2015
Merged

Support for humanizing DateTimeOffset #399

merged 4 commits into from
Mar 28, 2015

Conversation

tompazourek
Copy link
Contributor

I added support for humanizing DateTimeOffset (fixes #379).

It's one of my first pull requests ever, so please comment if I did not do something correctly.

To preserve the backwards compatibility, I did not change the IDateTimeHumanizeStrategy interface, but added new IDateTimeOffsetHumanizeStrategy interface.

The implementation of these strategies included in the library (DefaultDateTimeHumanizeStrategy and PrecisionDateTimeHumanizeStrategy) now implement both interfaces, since they share the same algorithm and 99% of the implementation. I thought this was the best solution so as not to introduce compatibility issues.

Support for the DateTimeOffset changes the public API (PublicApiApprovalTest.approve_public_api.approved.txt) a little bit. I am not sure what is the approval process for the API here, but I updated the API there.

Any feedback and ideas are welcome.

@MehdiK
Copy link
Member

MehdiK commented Mar 28, 2015

Hi @tompazourek. Awesome PR and we really needed this.

I am very keen to merge this in; but there are a couple of things I would do differently which I've commented on. Please address these, and leave me a comment and I will merge it.

P.S. I changed the description to say 'Fixes' instead of 'issue'. That will auto close the issue when PR's merged.

@@ -273,12 +273,13 @@ DateTime.UtcNow.AddHours(30).Humanize() => "tomorrow"
DateTime.UtcNow.AddHours(2).Humanize() => "2 hours from now"
Copy link
Member

Choose a reason for hiding this comment

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

Please add an example for DateTimeOffset here.

@MehdiK
Copy link
Member

MehdiK commented Mar 28, 2015

This is one clean first PR you've submitted. Awesome work. If you could just please fix the issues I pointed that would be awesome.

Please also add the PR to the releasenotes file. Cheers

@tompazourek tompazourek changed the title Initial implementation for humanizing DateTimeOffset. Support for humanizing DateTimeOffset Mar 28, 2015
@tompazourek
Copy link
Contributor Author

Thanks for the feedback. I separated the implementation of strategies for DateTime and DateTimeOffset, as you suggested. First I experimented with a base class for each pair of strategies, but I felt that the solution was too rigid and the class names were just too long and not nice. So I decided to move the two algorithms to separate internal static class. That way the code is very readable and clean, while not polluting the public API.

@MehdiK
Copy link
Member

MehdiK commented Mar 28, 2015

Cool. Thanks.

MehdiK added a commit that referenced this pull request Mar 28, 2015
Support for humanizing DateTimeOffset
@MehdiK MehdiK merged commit 3b3288a into Humanizr:master Mar 28, 2015
@MehdiK
Copy link
Member

MehdiK commented Mar 29, 2015

This is now released to NuGet as v1.35.0. Thanks for the contribution.

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.

Support for DateTimeOffset
2 participants