Precision

This commit is contained in:
2025-03-18 00:26:08 +01:00
parent 7f9e3f622a
commit 093679c9bb
7 changed files with 52 additions and 39 deletions

View File

@@ -2,13 +2,20 @@
namespace Jugenddienst_Stunden.Converter;
internal class SecondsTimeConverter : IValueConverter {
private int seconds;
/// <summary>
/// Konvertiert eine Sekundenangabe nach Stunden:Minuten, auch bei mehr als 24 Stunden
/// </summary>
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) {
if (value is null)
return "0:0";
if (value is int) {
seconds = (int)value;
}
if (value is double) {
seconds = (int)Math.Round((double)value);
} else {
int.TryParse((string?)value, out seconds);
}