40 lines
965 B
C#
40 lines
965 B
C#
using SteamWare;
|
|
using System;
|
|
|
|
namespace MoonProTablet
|
|
{
|
|
public class utility
|
|
{
|
|
/// <summary>
|
|
/// formatta la durata in minuti in un modo "human readable" gg/ore/min
|
|
/// </summary>
|
|
/// <param name="min">minuti</param>
|
|
/// <returns></returns>
|
|
public static string formatDurata(object min)
|
|
{
|
|
string answ = "";
|
|
DateTime tempo = new DateTime();
|
|
double minuti = 0;
|
|
try
|
|
{
|
|
minuti = Convert.ToDouble(min);
|
|
tempo = tempo.AddMinutes(minuti);
|
|
}
|
|
catch
|
|
{ }
|
|
if (minuti < memLayer.ML.CRI("maxMinuti"))
|
|
{
|
|
answ = string.Format("{0}m {1}s", tempo.Minute, tempo.Second);
|
|
}
|
|
else if (minuti < memLayer.ML.CRI("maxOre"))
|
|
{
|
|
answ = string.Format("{0}h {1}m", tempo.Hour, tempo.Minute);
|
|
}
|
|
else
|
|
{
|
|
answ = string.Format("{0}gg {1}h {2}m", tempo.DayOfYear, tempo.Hour, tempo.Minute);
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
} |