[chronojump] At Util better code for overloaded ConvertToPoint and GetSpeed
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] At Util better code for overloaded ConvertToPoint and GetSpeed
- Date: Wed, 31 Aug 2022 12:05:31 +0000 (UTC)
commit 3c9a8a7a1298c85a3b1d3cd7e65e65c79acd25d5
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Aug 31 14:04:55 2022 +0200
At Util better code for overloaded ConvertToPoint and GetSpeed
src/util.cs | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
---
diff --git a/src/util.cs b/src/util.cs
index 1830bf1e4..77123fb35 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -82,13 +82,9 @@ public class Util
//all numbers are saved in database with '.' as decimal separator (method for numbers)
public static string ConvertToPoint (double myDouble)
{
- StringBuilder myStringBuilder = new StringBuilder(myDouble.ToString());
- myStringBuilder.Replace(",", ".");
- return myStringBuilder.ToString();
+ return ConvertToPoint (myDouble.ToString ());
}
-
//all numbers are saved in database with '.' as decimal separator
- //method for the tvString, tcString, and runIntervalTimesString
public static string ConvertToPoint (string myString)
{
StringBuilder myStringBuilder = new StringBuilder(myString);
@@ -738,17 +734,17 @@ public class Util
}
- //public static string GetSpeed (string distance, string time) {
- public static string GetSpeed (string distance, string time, bool metersSecondsPreferred) {
- double distanceAsDouble = Convert.ToDouble(distance);
- double timeAsDouble = Convert.ToDouble(time);
-
+ public static string GetSpeed (string distance, string time, bool metersSecondsPreferred)
+ {
+ return GetSpeed (Convert.ToDouble (distance), Convert.ToDouble (time),
metersSecondsPreferred).ToString ();
+ }
+ public static double GetSpeed (double distance, double time, bool metersSecondsPreferred)
+ {
if(metersSecondsPreferred)
- return (distanceAsDouble / timeAsDouble).ToString();
+ return UtilAll.DivideSafe (distance, time);
else
- return (3.6 * distanceAsDouble / timeAsDouble).ToString();
+ return UtilAll.DivideSafe (3.6 * distance, time);
}
-
public static int FetchID (string text)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]