From 8afeb4d0943688ac267679c10e6c744e167275b2 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Tue, 1 Sep 2020 23:33:42 +0200 Subject: [PATCH] Add helpers for converting to and from Fahrenheit --- Content.Shared/Utility/TemperatureHelpers.cs | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Content.Shared/Utility/TemperatureHelpers.cs b/Content.Shared/Utility/TemperatureHelpers.cs index 1d4e61ca48..660af760fd 100644 --- a/Content.Shared/Utility/TemperatureHelpers.cs +++ b/Content.Shared/Utility/TemperatureHelpers.cs @@ -9,9 +9,31 @@ namespace Content.Shared.Utility return celsius + PhysicalConstants.ZERO_CELCIUS; } + public static float CelsiusToFahrenheit(float celsius) + { + return celsius * 9 / 5 + 32; + } + public static float KelvinToCelsius(float kelvin) { return kelvin - PhysicalConstants.ZERO_CELCIUS; } + + public static float KelvinToFahrenheit(float kelvin) + { + var celsius = KelvinToCelsius(kelvin); + return CelsiusToFahrenheit(celsius); + } + + public static float FahrenheitToCelsius(float fahrenheit) + { + return (fahrenheit - 32) * 5 / 9; + } + + public static float FahrenheitToKelvin(float fahrenheit) + { + var celsius = FahrenheitToCelsius(fahrenheit); + return CelsiusToKelvin(celsius); + } } }