I am wondering if someone who knows the implemention of python's time
could help converting this to c/c++....
nanoseconds = int(time.time() * 1e9)
# 0x01b21dd213814 000 is the number of 100-ns intervals between the
# UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01
00:00:00.
self.timestamp = int(nanoseconds/100) + 0x01b21dd213814 000L
self.clock_seq = random.randrang e(1<<14L) # instead of stable
storage
self.time_low = self.timestamp & 0xffffffffL
self.time_mid = (self.timestamp >32L) & 0xffffL
self.time_hi_ve rsion = (self.timestamp >48L) & 0x0fffL
self.clock_seq_ low = self.clock_seq & 0xffL
self.clock_seq_ hi_variant = (self.clock_seq >8L) & 0x3fL
#print 'timestamp ', self.timestamp, self.time_low, self.time_mid,
self.time_hi_ve rsion
#print 'clock_seq ', self.clock_seq, self.clock_seq_ low,
self.clock_seq_ hi_variant
vs unix gettimeofday... .
int gettimeofday(st ruct timeval *tp, struct timezone *tzp);
struct timeval {
long tv_sec; /* seconds since Jan. 1, 1970 */
long tv_usec; /* and microseconds */
};
struct timezone {
int tz_minuteswest; /* of Greenwich */
int tz_dsttime; /* type of dst correction to apply */
};
could help converting this to c/c++....
nanoseconds = int(time.time() * 1e9)
# 0x01b21dd213814 000 is the number of 100-ns intervals between the
# UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01
00:00:00.
self.timestamp = int(nanoseconds/100) + 0x01b21dd213814 000L
self.clock_seq = random.randrang e(1<<14L) # instead of stable
storage
self.time_low = self.timestamp & 0xffffffffL
self.time_mid = (self.timestamp >32L) & 0xffffL
self.time_hi_ve rsion = (self.timestamp >48L) & 0x0fffL
self.clock_seq_ low = self.clock_seq & 0xffL
self.clock_seq_ hi_variant = (self.clock_seq >8L) & 0x3fL
#print 'timestamp ', self.timestamp, self.time_low, self.time_mid,
self.time_hi_ve rsion
#print 'clock_seq ', self.clock_seq, self.clock_seq_ low,
self.clock_seq_ hi_variant
vs unix gettimeofday... .
int gettimeofday(st ruct timeval *tp, struct timezone *tzp);
struct timeval {
long tv_sec; /* seconds since Jan. 1, 1970 */
long tv_usec; /* and microseconds */
};
struct timezone {
int tz_minuteswest; /* of Greenwich */
int tz_dsttime; /* type of dst correction to apply */
};
Comment