2022-12-06 16:14:56 -06:00
|
|
|
// *********************************** unit conversions ***********************
|
|
|
|
|
|
2022-12-12 14:47:53 -06:00
|
|
|
const round2 = (value, decimals) => Math.trunc(value * 10 ** decimals) / 10 ** decimals;
|
2022-11-22 16:19:10 -06:00
|
|
|
|
2023-01-06 14:39:39 -06:00
|
|
|
const kphToMph = (Kph) => Math.round(Kph / 1.609_34);
|
2022-11-22 16:19:10 -06:00
|
|
|
const celsiusToFahrenheit = (Celsius) => Math.round((Celsius * 9) / 5 + 32);
|
2023-01-06 14:39:39 -06:00
|
|
|
const kilometersToMiles = (Kilometers) => Math.round(Kilometers / 1.609_34);
|
2022-11-22 16:19:10 -06:00
|
|
|
const metersToFeet = (Meters) => Math.round(Meters / 0.3048);
|
2023-01-06 14:39:39 -06:00
|
|
|
const pascalToInHg = (Pascal) => round2(Pascal * 0.000_295_3, 2);
|
2022-11-22 16:19:10 -06:00
|
|
|
|
2022-12-06 16:25:28 -06:00
|
|
|
export {
|
2022-11-22 16:19:10 -06:00
|
|
|
kphToMph,
|
|
|
|
|
celsiusToFahrenheit,
|
|
|
|
|
kilometersToMiles,
|
|
|
|
|
metersToFeet,
|
|
|
|
|
pascalToInHg,
|
2022-12-12 14:47:53 -06:00
|
|
|
round2,
|
2022-11-22 16:19:10 -06:00
|
|
|
};
|