On Thu, 14 Jun 2007 13:16:42 -0700, SpreadTooThin <[EMAIL PROTECTED]> wrote: > 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)
[straightforward non-time arithmetic snipped] > > 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 */ > }; Quite simply, time.time() corresponds to tv_sec + tv_usec/1e6, modulo any rounding and numerical errors introduced by the floating-point format used. > struct timezone { > int tz_minuteswest; /* of Greenwich */ > int tz_dsttime; /* type of dst correction to apply */ > }; The struct timezone is not set by Linux/glibc gettimeofday(), so you can happily ignore it. You only want UTC time anyway. /Jorgen -- // Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu \X/ snipabacken.dyndns.org> R'lyeh wgah'nagl fhtagn! -- http://mail.python.org/mailman/listinfo/python-list