1  protected static readonly DateTime unixTPStart =
 2                   TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(197011));
 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
 posted on 2007-12-30 22:33  !@SJ$s  阅读(588)  评论(0编辑  收藏  举报