Files

23 lines
635 B
C#
Raw Permalink Normal View History

namespace MtApi
2014-10-31 09:05:52 +02:00
{
class MtApiTimeConverter
{
public static DateTime ConvertFromMtTime(int time)
{
DateTime tmpTime = new(1970, 1, 1);
2014-10-31 09:05:52 +02:00
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(1970, 1, 1);
result = (int)((time.Value.Ticks - tmpTime.Ticks) / 0x989680L);
2014-10-31 09:05:52 +02:00
}
return result;
}
}
}