roadie/Roadie.Api.Library/Extensions/IntEx.cs
2018-12-26 13:39:13 -06:00

26 lines
No EOL
684 B
C#

using System;
namespace Roadie.Library.Extensions
{
public static class IntEx
{
public static int? Or(this int? value, int? alternative)
{
if (!value.HasValue && !alternative.HasValue)
{
return null;
}
return value.HasValue ? value : alternative;
}
public static int ToSecondsFromMilliseconds(this int? value)
{
if (value > 0)
{
var contentDurationTimeSpan = TimeSpan.FromMilliseconds((double)(value ?? 0));
return (int)contentDurationTimeSpan.TotalSeconds;
}
return 0;
}
}
}