我目前正在处理一个使用未知时间戳机制的系统。
系统在Windows机器上运行,所以我首先想到的是它使用某种Windows纪元作为其时间戳,但它似乎没有。
我的目标是将这些时间戳转换为Unix时间戳。
几个例子:
以下时间戳: 2111441659转换为: 2013-10-01 11:59
2111441998至2013-10-01 17:14 2111443876至2013-10-02 14:36 2111444089至2013-10-02 17:57(所有日期均为GMT + 2)
我已经尝试使用上面的数据计算参考日期,但不知何故,我得到了每个时间戳的不同结果。
任何人都可以对这个相当奇怪的问题有所了解吗?
提前致谢!
I'm currently dealing with a system which uses an unknown timestamp mechanism.
The system is running on a Windows machine, so my first thought was that it uses some kind of Windows epoch for its timestamps, but it appears it does not.
My goal is to convert these timestamps to Unix timestamps.
A few examples:
The following timestamp: 2111441659 converts to: 2013-10-01 11:59
2111441998 to 2013-10-01 17:14 2111443876 to 2013-10-02 14:36 2111444089 to 2013-10-02 17:57(All dates are GMT+2)
I've tried to calculate the reference date using the data above, but somehow I get a different result with every single timestamp.
Could anybody shed some light on this rather odd problem?
Thanks in advance!
最满意答案
对我来说,数字似乎很小,只有几毫秒。 我的第一个猜测是秒,但看着这个数字变化的速度,我认为分钟是一个更好的猜测。 做一些数学计算2111441659/60/24/365 = 4017.20254756这表明时代可能是在-2000年的某个时间?
这是计算中常见时代的列表,但是-2000年并不是真的存在:)你如何获得这个时间戳?
PS你确定这台机器的年份设定为2013年而不是4013吗? :)这将适合1年1月1日的.NET纪元
Finally, after many hours of comparing the timestamps with the datetimes, trying to discover the logic between them, I've found the answer by reverse engineering the software which generates the timestamps.
It turns out that the integer timestamps are actually bitwise representations* of the datetimes.
In pseudocode:
year = TimeStamp >> 20; month = (TimeStamp >> 16) & 15; day = (TimeStamp >> 11) & 31; hour = (TimeStamp >> 6) & 31; minute = TimeStamp & 63;*I'm not sure if this is the correct term for it, if not, please correct me.
更多推荐
发布评论