-
Notifications
You must be signed in to change notification settings - Fork 967
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
583 years and months #604
583 years and months #604
Conversation
Fixes string resolution of a tiespan including years and months
months += monthCount; | ||
|
||
return months; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better to write 142-162 as:
for (var monthCount = 0; daysRemaining > _daysInMonths[monthCount]; monthCount++)
daysRemaining -= _daysInMonths[monthCount];
return isTimeUnitToGetTheMaximumTimeUnit
? months + monthCount
: daysRemaining;
I didnt test it. So feel free to change anything else ;)
return timespan.Days % _daysInAWeek; | ||
} | ||
return (int)(timespan.TotalDays%_daysInAYear); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also
{
return (int)(isTimeUnitToGetTheMaximumTimeUnit
? Math.Floor(timespan.TotalDays / _daysInAYear)
: timespan.TotalDays % _daysInAYear);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can benefit of ternary operator further 👍
} | ||
private static List<string> CreateTimePartsWithNoTimeValue(string noTimeValue) | ||
{ | ||
return new List<string>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the ()
} | ||
private static bool IsContainingOnlyNullValue(IEnumerable<string> timeParts) | ||
{ | ||
return (timeParts.Count(x => x != null) == 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove the ( )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add some tests?
@@ -8,190 +8,235 @@ | |||
|
|||
namespace Humanizer | |||
{ | |||
/// <summary> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem to obey the .editorconfig
, stating 4 spaces.
This makes the diff much larger than it's supposed to.
@reinhardtb Thanks for the contribution. This has been sitting here idly for about a year now. Could you please address the comments, do a rebase and push force? Please also fix the whitespace diffs as they make it hard to review the code. Please leave us a comment. Thanks. |
Actually I will close this for now. Please submit a new PR and we'll review. |
Fixes string resolution of a timespan including years and months