Skip to content

Commit 0d55389

Browse files
authored
Fix: Fixed duration formatting when it is more than one day (#12314)
1 parent ddd5171 commit 0d55389

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Files.App/ViewModels/Properties/Items/FileProperty.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,15 @@ public async static Task<List<FileProperty>> RetrieveAndInitializePropertiesAsyn
324324
private static readonly Dictionary<string, Func<object, string>> DisplayFuncs = new Dictionary<string, Func<object, string>>()
325325
{
326326
{ "DivideBy1000", input => (((uint) input)/1000).ToString() },
327-
{ "FormatDuration", input => new TimeSpan(Convert.ToInt64(input)).ToString("hh':'mm':'ss")},
327+
{ "FormatDuration", input => TimeSpanToString(new TimeSpan(Convert.ToInt64(input)))},
328328
{ "Fraction" , input => ((double)input).ToFractions(2000)},
329329
{ "AddF" , input => $"f/{(double)input}"},
330330
{ "AddISO" , input => $"ISO-{(UInt16)input}"},
331331
{ "RoundDouble" , input => $"{Math.Round((double)input)}"},
332332
{ "UnitMM" , input => $"{(double)input} mm"},
333333
};
334+
335+
private static string TimeSpanToString(TimeSpan t)
336+
=> t.Days > 0 ? (t.Days * 24 + t.Hours) + t.ToString("':'mm':'ss") : t.ToString("hh':'mm':'ss");
334337
}
335338
}

0 commit comments

Comments
 (0)