mirror of
https://github.com/sphildreth/roadie
synced 2024-11-26 14:10:21 +00:00
20 lines
No EOL
535 B
C#
20 lines
No EOL
535 B
C#
using System;
|
|
|
|
namespace Roadie.Library.Extensions
|
|
{
|
|
public static class DateTimeExt
|
|
{
|
|
public static DateTime FromUnixTime(this long unixTime)
|
|
{
|
|
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
|
return epoch.AddSeconds(unixTime);
|
|
}
|
|
|
|
public static long ToUnixTime(this DateTime date)
|
|
{
|
|
var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
|
return Convert.ToInt64((date - epoch).TotalSeconds);
|
|
}
|
|
|
|
}
|
|
} |