如何比较GDKEvent时间戳与当前时间? [英] How to compare GDKEvent timestamp with current time?
问题描述
如何在c ++中使用GDKEvent的时间戳?
例如,我将其作为unsigned int打印,其值为4194719109,但当前时间为1395764110,它是从time.h的time()获取的。 g_get_real_time()的当前时间是1395764110872217,它是一个gint64类型值。看起来g_get_real_time()比time()更精确。
How to use the GDKEvent's timestamp in c++? For example, I print it as unsigned int, its value is 4194719109, but the current time is 1395764110 which is gotten from time() of time.h. The current time of g_get_real_time() is 1395764110872217 which is a gint64 type value. it seems the g_get_real_time() is more accurate than time().
我的目的是计算它从GDKEvent发生的时间持续了多少次。
My purpose is to calculate how many times it has lasted from the time of GDKEvent occurred.
推荐答案
时间元素
GdkEvent
以毫秒为单位。与 g_get_monotonic_time()
(以μs为单位)除以 1000
应该工作(确保检查符号和在比较之前转换为 guint32
)
The time
element of GdkEvent
is in miliseconds. Comparing with g_get_monotonic_time()
(which is in µs) divided by 1000
should work (make sure to check the sign and cast to guint32
before comparing)
这篇关于如何比较GDKEvent时间戳与当前时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!