ws4kp/server/scripts/modules/utils/units.mjs
2023-11-11 19:54:58 -08:00

20 lines
659 B
JavaScript

// *********************************** unit conversions ***********************
const round2 = (value, decimals) => Math.trunc(value * 10 ** decimals) / 10 ** decimals;
const kphToMph = (Kph) => Math.round(Kph / 1.609_34);
// HACK!
const celsiusToFahrenheit = (Celsius) => Celsius; // Math.round((Celsius * 9) / 5 + 32);
const kilometersToMiles = (Kilometers) => Kilometers; // Math.round(Kilometers / 1.609_34);
const metersToFeet = (Meters) => Meters; // Math.round(Meters / 0.3048);
const pascalToInHg = (Pascal) => round2(Pascal * 0.000_295_3, 2);
export {
kphToMph,
celsiusToFahrenheit,
kilometersToMiles,
metersToFeet,
pascalToInHg,
round2,
};