OLE Automation Date in Lua [英] OLE Automation date in lua
本文介绍了OLE Automation Date in Lua的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好吧,我真的需要lua中的OLE自动化日期.
Ok, I really need OLE Automation date in lua.
从此处:
公共双ToOADate()
public double ToOADate()
返回值类型:System.Double一个双精度浮点数包含OLE自动化日期的数字,该日期等于这个实例.
Return Value Type: System.Double A double-precision floating-point number that contains an OLE Automation date equivalent to the value of this instance.
因此在C#中:
Console.Write("DateTime.Now.ToOADate() = " + DateTime.Now.ToOADate());
给我这个:
DateTime.Now.ToOADate() = 42146,4748270602
在Lua中获得类似价值的最佳方法是什么?
What is the best way to get simular value in Lua?
推荐答案
基于EgorSkriptunoff答案的更多详细信息.
Some more details, based on EgorSkriptunoff answer.
因此,Lua代码对我来说可以很好地在lua中获取OLE自动化日期:
So, that Lua code works just fine for me to get OLE Automation date in lua:
-- number of days between December, 30 1899 and January, 1 1970
local magicnumber = 25569
-- don't forget about time zone (UTC+3 for my case)
local utcshift = 3*3600
-- calc and print for test
local oleadate = magicnumber + ((os.time()+utcshift)/(3600*24))
print(oleadate)
输出:
42146.575740741
这篇关于OLE Automation Date in Lua的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文