[PTRun][UnitConverter]Use capital letters in DegreePrefixer (#34845)

* [Run-UnitConverter] Use capital letters in DegreePrefixer

* doc update

* Update tests

* Remove FeetToFt

* trigger checks
This commit is contained in:
PesBandi
2024-09-25 14:59:49 +02:00
committed by GitHub
parent bbad1eb461
commit 7c48f5ebd2
4 changed files with 14 additions and 31 deletions

View File

@@ -92,7 +92,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
if (!isFeet || !isInches)
{
// atleast one could not be parsed correctly
// at least one could not be parsed correctly
break;
}
@@ -115,7 +115,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
}
/// <summary>
/// Adds degree prefixes to degree units for shorthand notation. E.g. '10 c in fahrenheit' becomes '10 °c in DegreeFahrenheit'.
/// Adds degree prefixes to degree units for shorthand notation. E.g. '10 c in fahrenheit' becomes '10 °C in DegreeFahrenheit'.
/// </summary>
public static void DegreePrefixer(ref string[] split)
{
@@ -130,11 +130,11 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
break;
case "c":
split[1] = c";
split[1] = C";
break;
case "f":
split[1] = f";
split[1] = F";
break;
default:
@@ -152,11 +152,11 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
break;
case "c":
split[3] = c";
split[3] = C";
break;
case "f":
split[3] = f";
split[3] = F";
break;
default:
@@ -164,22 +164,6 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
}
}
/// <summary>
/// The plural form "feet" is not recognized by UniteNets. Replace it with "ft".
/// </summary>
public static void FeetToFt(ref string[] split)
{
if (string.Equals(split[1], "feet", StringComparison.OrdinalIgnoreCase))
{
split[1] = "ft";
}
if (string.Equals(split[3], "feet", StringComparison.OrdinalIgnoreCase))
{
split[3] = "ft";
}
}
/// <summary>
/// Converts spelling "kph" to "km/h"
/// </summary>
@@ -292,7 +276,6 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
InputInterpreter.DegreePrefixer(ref split);
InputInterpreter.MetreToMeter(ref split);
InputInterpreter.FeetToFt(ref split);
InputInterpreter.KPHHandler(ref split);
InputInterpreter.GallonHandler(ref split, CultureInfo.CurrentCulture);
InputInterpreter.OunceHandler(ref split, CultureInfo.CurrentCulture);

View File

@@ -11,7 +11,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
{
public static class UnitHandler
{
private static readonly int _roundingFractionalDigits = 4;
private static readonly int _roundingSignificantDigits = 4;
private static readonly QuantityInfo[] _included = new QuantityInfo[]
{
@@ -72,7 +72,7 @@ namespace Community.PowerToys.Run.Plugin.UnitConverter
var power = Math.Floor(Math.Log10(Math.Abs(value)));
var exponent = Math.Pow(10, power);
var rounded = Math.Round(value / exponent, _roundingFractionalDigits) * exponent;
var rounded = Math.Round(value / exponent, _roundingSignificantDigits) * exponent;
return rounded;
}