1
protected static readonly DateTime unixTPStart =
2
TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
3
public static long toUTP(DateTime dt)
4
{
5
TimeSpan toNow = dt.Subtract(unixTPStart);
6
return (long)Math.Round(toNow.TotalSeconds);
7
}
8
public static DateTime fromUTP(long tp)
9
{
10
return unixTPStart.Add(new TimeSpan(tp * 10000000));
11
}
12

2

3

4

5

6

7

8

9

10

11

12
