49 lines
1.2 KiB
C#
49 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Maser.Feanor.Model
|
|
{
|
|
public static class Time
|
|
{
|
|
public static DateTime UnixToDatetime(Int32 UnixStamp)
|
|
{
|
|
DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0);
|
|
return dt.AddSeconds(UnixStamp);
|
|
}
|
|
|
|
public static Int32 DatetimeToUnix(DateTime datetime)
|
|
{
|
|
return (Int32)(datetime.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
|
|
}
|
|
|
|
|
|
public static DateTime UTC
|
|
{ // Return UTC time
|
|
get {return DateTime.Now.ToUniversalTime(); }
|
|
}
|
|
|
|
public static DateTime Local
|
|
{
|
|
// Return the local time in The Netherlands
|
|
get {return DateTime.Now; }
|
|
}
|
|
|
|
|
|
public static DateTime LocalToUtc(DateTime Local)
|
|
{
|
|
// Return the UTC time at given local time in The Netherlands
|
|
return Local.ToUniversalTime();
|
|
}
|
|
|
|
public static DateTime UtcToLocal(DateTime UTC)
|
|
{
|
|
// Return the local time in The Netherlands at given UTC time
|
|
return UTC.ToLocalTime();
|
|
}
|
|
|
|
}
|
|
}
|