This commit adds a function, ply_get_timestamp(), that returns
the current time in seconds since the epoch as a double.
close (fd);
}
+double
+ply_get_timestamp (void)
+{
+ const double microseconds_per_second = 1000000.0;
+ double timestamp;
+ struct timeval now = { 0L, /* zero-filled */ };
+
+ gettimeofday (&now, NULL);
+ timestamp = ((microseconds_per_second * now.tv_sec) + now.tv_usec) /
+ microseconds_per_second;
+
+ return timestamp;
+}
+
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */
char **ply_copy_string_array (const char * const *array);
void ply_free_string_array (char **array);
void ply_close_all_fds (void);
+double ply_get_timestamp (void);
#endif
#endif /* PLY_UTILS_H */