ulua lua中的时间戳实现中出现的数值类型问题,long错误不能识别的解决方案

来源:互联网 发布:java 运算 类型 提升 编辑:程序博客网 时间:2024/06/06 00:36

ulua中的时间戳

第一种c#方法:

/// <summary>        /// Gets the time.  cgq“yeg°ãó{        /// </summary>        /// <returns>The time.</returns>        public static double GetTime() {            TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - new DateTime(1970, 1, 1, 0, 0, 0).Ticks);            return Math.Ceiling(ts.TotalMilliseconds/1000);        }        /// <summary>        /// Gets the time unix stamp.        /// </summary>        /// <returns>The time unix stamp.</returns>        public static double GetTimeUnixStamp() {            TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - new DateTime(1970, 1, 1, 0, 0, 0).Ticks);            return Math.Ceiling(ts.TotalMilliseconds);        }

这两种我都是用double去代替了,第二个方法精确一些,毫秒计时
因为double, int ,lua 可以很好的识别无需更改,转换,穿进去就是number了,直接用,简单

当然上面再怎么好也不如原生的:

--直接获取出来就是秒级别的时间戳不是毫秒计时,毫秒要用还是用c#实现os.time()

总体是解决了,
但是还是希望有long支持,简单高效

0 0
原创粉丝点击