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

remove some bool expressions where the result is known #1400

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ string Convert(int number, bool isOrdinal)
var lastPart = TensMap[number / 10];
if (number % 10 > 0)
{
lastPart = $"{GetUnitValue(number % 10, false)} en {(isOrdinal ? GetUnitValue(lastPartValue, isOrdinal) : lastPart)}";
lastPart = $"{GetUnitValue(number % 10, false)} en {(isOrdinal ? GetUnitValue(lastPartValue, true) : lastPart)}";
}
else if (number % 10 == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public override string Convert(long input)
number %= 100;
}

if (number >= 20 && number / 10 > 0)
if (number >= 20)
{
parts.Add($"{Convert(number / 10)}kymmentä");
number %= 10;
Expand Down Expand Up @@ -128,7 +128,7 @@ static string ToOrdinal(int number, bool useExceptions)
number %= 100;
}

if (number >= 20 && number / 10 > 0)
if (number >= 20)
{
parts.Add($"{ToOrdinal(number / 10, true)}kymmenes");
number %= 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public override string ConvertToOrdinal(int number)
}

// suffix -de/-te
if (divided > 0 && number % m.Value == 0)
if (number % m.Value == 0)
{
switch (number)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Humanizer/TimeSpanHumanizeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static IEnumerable<string> CreateTheTimePartsWithUpperAndLowerLimits(TimeSpan ti
if (IsContainingOnlyNullValue(timeParts))
{
var noTimeValueCultureFormatted = toWords ? cultureFormatter.TimeSpanHumanize_Zero()
: cultureFormatter.TimeSpanHumanize(minUnit, 0, toWords);
: cultureFormatter.TimeSpanHumanize(minUnit, 0);
timeParts = CreateTimePartsWithNoTimeValue(noTimeValueCultureFormatted);
}
return timeParts;