Convert to C/C++?
SpreadTooThin
bjobrien62 at gmail.com
Thu Jun 14 16:16:42 EDT 2007
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)
# 0x01b21dd213814000 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) + 0x01b21dd213814000L
self.clock_seq = random.randrange(1<<14L) # instead of stable
storage
self.time_low = self.timestamp & 0xffffffffL
self.time_mid = (self.timestamp >> 32L) & 0xffffL
self.time_hi_version = (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_version
#print 'clock_seq ', self.clock_seq, self.clock_seq_low,
self.clock_seq_hi_variant
vs unix gettimeofday....
int gettimeofday(struct 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 */
};
More information about the Python-list
mailing list