Client - refacto util functions for temperature and wind speed

This commit is contained in:
Sam
2022-11-17 00:20:21 +01:00
parent 940f0a8416
commit 546315e218
4 changed files with 68 additions and 18 deletions

View File

@ -1,8 +1,6 @@
<template>
<div class="wind">
{{ useImperialUnits ?
convert_mps_to_mph(Number(weather.wind)).toFixed(1) + ' mph' :
Number(weather.wind).toFixed(1) + " m/s" }}
{{ getWindSpeed(weather.wind, useImperialUnits) }}
<div class="wind-bearing">
<i
v-if="weather.windBearing"
@ -22,6 +20,7 @@
import { useI18n } from 'vue-i18n'
import { IWeather } from '@/types/workouts'
import { getWindSpeed } from '@/utils/units'
import { convertDegreeToDirection } from '@/utils/weather'
interface Props {
@ -40,10 +39,6 @@
)}`
)
}
function convert_mps_to_mph(windSpeed: number): number {
return windSpeed * 2.2369363
}
</script>
<style lang="scss" scoped>

View File

@ -58,14 +58,20 @@
/>
</td>
<td>
{{ useImperialUnits ?
convertCelsiusToFahrenheit(Number(workoutObject.weatherStart.temperature)).toFixed(1) + " °F" :
Number(workoutObject.weatherStart.temperature).toFixed(1) + " °C"}}
{{
getTemperature(
workoutObject.weatherStart.temperature,
useImperialUnits
)
}}
</td>
<td>
{{ useImperialUnits ?
convertCelsiusToFahrenheit(Number(workoutObject.weatherEnd.temperature)).toFixed(1) + " °F" :
Number(workoutObject.weatherEnd.temperature).toFixed(1) + " °C"}}
{{
getTemperature(
workoutObject.weatherEnd.temperature,
useImperialUnits
)
}}
</td>
</tr>
<tr>
@ -116,6 +122,7 @@
import WeatherWind from '@/components/Workout/WorkoutDetail/WeatherWind.vue'
import { IWorkoutObject } from '@/types/workouts'
import { getTemperature } from '@/utils/units'
interface Props {
workoutObject: IWorkoutObject
@ -124,10 +131,6 @@
const props = defineProps<Props>()
const { useImperialUnits, workoutObject } = toRefs(props)
function convertCelsiusToFahrenheit(celsius_temp: number): number {
return celsius_temp * 1.8 + 32
}
</script>
<style lang="scss" scoped>