mirror of
https://github.com/sphildreth/roadie
synced 2024-11-26 06:00:23 +00:00
27 lines
No EOL
667 B
C#
27 lines
No EOL
667 B
C#
using System;
|
|
|
|
namespace Roadie.Library.Extensions
|
|
{
|
|
public static class DecimalExt
|
|
{
|
|
public static int ToSecondsFromMilliseconds(this decimal? value)
|
|
{
|
|
if (value > 0)
|
|
{
|
|
var contentDurationTimeSpan = TimeSpan.FromMilliseconds((double)(value ?? 0));
|
|
return (int)contentDurationTimeSpan.TotalSeconds;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public static TimeSpan? ToTimeSpan(this decimal? value)
|
|
{
|
|
if (!value.HasValue)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return TimeSpan.FromSeconds((double)value);
|
|
}
|
|
}
|
|
} |