mirror of
https://github.com/fergalmoran/podnoms.git
synced 2025-12-25 10:47:51 +00:00
21 lines
600 B
C#
Executable File
21 lines
600 B
C#
Executable File
using System;
|
|
|
|
namespace PodNoms.Api.Utils
|
|
{
|
|
|
|
public class DateUtils
|
|
{
|
|
public static DateTime ConvertFromUnixTimestamp(double timestamp)
|
|
{
|
|
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
|
return origin.AddSeconds(timestamp);
|
|
}
|
|
|
|
public static double ConvertToUnixTimestamp(DateTime date)
|
|
{
|
|
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
|
|
TimeSpan diff = date.ToUniversalTime() - origin;
|
|
return Math.Floor(diff.TotalSeconds);
|
|
}
|
|
}
|
|
} |