2024-06-16 13:57:50 +03:00
|
|
|
namespace MtApi
|
2014-10-31 09:05:52 +02:00
|
|
|
{
|
|
|
|
|
class MtApiTimeConverter
|
|
|
|
|
{
|
|
|
|
|
public static DateTime ConvertFromMtTime(int time)
|
|
|
|
|
{
|
2024-06-16 13:57:50 +03:00
|
|
|
DateTime tmpTime = new(1970, 1, 1);
|
2014-10-31 09:05:52 +02:00
|
|
|
return new DateTime(tmpTime.Ticks + (time * 0x989680L));
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-30 17:16:48 +02:00
|
|
|
public static int ConvertToMtTime(DateTime? time)
|
2014-10-31 09:05:52 +02:00
|
|
|
{
|
|
|
|
|
int result = 0;
|
2016-12-30 17:16:48 +02:00
|
|
|
if (time != null && time != DateTime.MinValue)
|
2014-10-31 09:05:52 +02:00
|
|
|
{
|
2024-06-16 13:57:50 +03:00
|
|
|
DateTime tmpTime = new(1970, 1, 1);
|
2016-12-30 17:16:48 +02:00
|
|
|
result = (int)((time.Value.Ticks - tmpTime.Ticks) / 0x989680L);
|
2014-10-31 09:05:52 +02:00
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|