Closed tylerstambaugh closed 2 months ago
private XomsTimes GetXomTimeFromStrings(Xoms xoms) { return new XomsTimes { KomTime = GetTimeFromString(xoms.Kom), QomTime = GetTimeFromString(xoms.Qom) }; }
private int GetTimeFromString(string time) { time = RemoveLetters(time);
int returnTime = 0; string[] timeParts = time.Split(':'); for (int i = 0; i <= timeParts.Length - 1; i++) { int factor = (int)Math.Pow(60, i); returnTime += int.Parse(timeParts[timeParts.Length - (i + 1)]) * factor; } return returnTime;
}
private string RemoveLetters(string input) { Regex regex = new Regex("[^0-9:]"); return regex.Replace(input, ""); }
private class XomsTimes { public int KomTime { get; set; } public int QomTime { get; set; } }
private string ConvertTimeInSeconds(int seconds) { int hours = seconds / 3600; int minutes = seconds / 60 - (hours 60); int remainingSeconds = seconds - ((hours 3600) + (minutes * 60));
var timeAsString = ""; if(hours > 0) { timeAsString = $"{hours:D2}:{minutes:D2}:{Math.Abs(remainingSeconds):D2}"; } if(hours == 0) { timeAsString = $"{minutes:D2}:{Math.Abs(remainingSeconds):D2}"; } if (remainingSeconds < 0) { timeAsString = $"-{timeAsString}"; } return timeAsString;
should be put into their own helper class.
this has been implemented
private XomsTimes GetXomTimeFromStrings(Xoms xoms) { return new XomsTimes { KomTime = GetTimeFromString(xoms.Kom), QomTime = GetTimeFromString(xoms.Qom) }; }
private int GetTimeFromString(string time) { time = RemoveLetters(time);
}
private string RemoveLetters(string input) { Regex regex = new Regex("[^0-9:]"); return regex.Replace(input, ""); }
private class XomsTimes { public int KomTime { get; set; } public int QomTime { get; set; } }
private string ConvertTimeInSeconds(int seconds) { int hours = seconds / 3600; int minutes = seconds / 60 - (hours 60); int remainingSeconds = seconds - ((hours 3600) + (minutes * 60));
}
should be put into their own helper class.