From 0931dfc5b104220fc2d17ee2ff71eec48b11ecf1 Mon Sep 17 00:00:00 2001 From: Joshua Taillon Date: Mon, 7 Nov 2022 14:52:21 -0700 Subject: [PATCH] Customize weather temperature display based on unit setting --- .../Workout/WorkoutDetail/WorkoutWeather.vue | 12 ++++++++++-- fittrackee_client/src/locales/de/user.json | 4 ++-- fittrackee_client/src/locales/en/user.json | 6 +++--- fittrackee_client/src/locales/fr/user.json | 6 +++--- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/fittrackee_client/src/components/Workout/WorkoutDetail/WorkoutWeather.vue b/fittrackee_client/src/components/Workout/WorkoutDetail/WorkoutWeather.vue index 83863f5e..fc4fab4f 100644 --- a/fittrackee_client/src/components/Workout/WorkoutDetail/WorkoutWeather.vue +++ b/fittrackee_client/src/components/Workout/WorkoutDetail/WorkoutWeather.vue @@ -58,10 +58,14 @@ /> - {{ Number(workoutObject.weatherStart.temperature).toFixed(1) }}°C + {{ useImperialUnits ? + convertCelsiusToFahrenheit(Number(workoutObject.weatherStart.temperature)).toFixed(1) + " °F" : + Number(workoutObject.weatherStart.temperature).toFixed(1) + " °C"}} - {{ Number(workoutObject.weatherEnd.temperature).toFixed(1) }}°C + {{ useImperialUnits ? + convertCelsiusToFahrenheit(Number(workoutObject.weatherEnd.temperature)).toFixed(1) + " °F" : + Number(workoutObject.weatherEnd.temperature).toFixed(1) + " °C"}} @@ -120,6 +124,10 @@ const props = defineProps() const { useImperialUnits, workoutObject } = toRefs(props) + + function convertCelsiusToFahrenheit(celsius_temp: number): number { + return celsius_temp * 1.8 + 32 + }