29 lines
844 B
C#
29 lines
844 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Chrosey.Extensions
|
|
{
|
|
public static class NumberExtensions
|
|
{
|
|
public static string ToTimeSpanString(this int minutes, bool noNegative = false)
|
|
{
|
|
if (noNegative)
|
|
{
|
|
return string.Format("{0}:{1}"
|
|
, (Math.Abs(minutes / 60)).ToString().PadLeft(2)
|
|
, (Math.Abs(minutes % 60)).ToString().PadLeft(2, '0')
|
|
);
|
|
}
|
|
|
|
return string.Format("{2}{0}:{1}"
|
|
, (Math.Abs(minutes / 60)).ToString().PadLeft(3)
|
|
, (Math.Abs(minutes % 60)).ToString().PadLeft(2, '0')
|
|
, minutes < 0 ? "-" : " "
|
|
);
|
|
}
|
|
}
|
|
}
|