mirror of
https://github.com/fergalmoran/podnoms.git
synced 2025-12-22 09:18:08 +00:00
16 lines
579 B
C#
16 lines
579 B
C#
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);
|
|
}
|
|
}
|
|
} |