Files
mtapi/MtApi/MtApiTimeConverter.cs
T

28 lines
745 B
C#
Raw Normal View History

2014-10-31 09:05:52 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MtApi
{
class MtApiTimeConverter
{
public static DateTime ConvertFromMtTime(int time)
{
DateTime tmpTime = new DateTime(1970, 1, 1);
return new DateTime(tmpTime.Ticks + (time * 0x989680L));
}
public static int ConvertToMtTime(DateTime? time)
2014-10-31 09:05:52 +02:00
{
int result = 0;
if (time != null && time != DateTime.MinValue)
2014-10-31 09:05:52 +02:00
{
DateTime tmpTime = new DateTime(1970, 1, 1);
result = (int)((time.Value.Ticks - tmpTime.Ticks) / 0x989680L);
2014-10-31 09:05:52 +02:00
}
return result;
}
}
}