diff --git a/MP-TAB-SERV/Components/MachineBlock.razor b/MP-TAB-SERV/Components/MachineBlock.razor index 40234416..1e873a49 100644 --- a/MP-TAB-SERV/Components/MachineBlock.razor +++ b/MP-TAB-SERV/Components/MachineBlock.razor @@ -48,7 +48,7 @@ else
- @RecMSE.DescrizioneStato:   @(formatDurata(RecMSE.Durata)) + @RecMSE.DescrizioneStato:   @(FormatDurata(RecMSE.Durata))
@@ -95,7 +95,7 @@ else
@RecMSE.Nome
- @RecMSE.DescrizioneStato:   @(formatDurata(RecMSE.Durata)) + @RecMSE.DescrizioneStato:   @(FormatDurata(RecMSE.Durata))
@if (showCard) @@ -241,7 +241,7 @@ else @RecMSE.DescrizioneStato :
- @(formatDurata(RecMSE.Durata)) + @(FormatDurata(RecMSE.Durata))
diff --git a/MP-TAB-SERV/Components/MachineBlock.razor.cs b/MP-TAB-SERV/Components/MachineBlock.razor.cs index 5fe42ba1..14c65654 100644 --- a/MP-TAB-SERV/Components/MachineBlock.razor.cs +++ b/MP-TAB-SERV/Components/MachineBlock.razor.cs @@ -41,27 +41,22 @@ namespace MP_TAB_SERV.Components /// /// minuti /// - public static string formatDurata(double? minuti) + public static string FormatDurata(double? minuti) { string answ = "??"; - if (minuti != null) + TimeSpan tempo = TimeSpan.FromMinutes(minuti ?? 0); + if (tempo.TotalMinutes < 60) { - DateTime tempo = new DateTime(); - tempo = tempo.AddMinutes((double)minuti); - if (minuti < 60) - { - answ = $"{tempo.Minute:00}:{tempo.Second:00}"; - } - else if (minuti < 1440) - { - answ = $"{tempo.Hour}h {tempo.Minute}m"; - } - else - { - answ = $"{tempo.DayOfYear}g {tempo.Hour}h"; - } + answ = $"{tempo.Minutes:00}:{tempo.Seconds:00}"; + } + else if (tempo.TotalHours < 24) + { + answ = $"{tempo.Hours}h {tempo.Minutes}m"; + } + else + { + answ = $"{tempo.Days}g {tempo.Hours}h"; } - return answ; }