added function to convert double to struct timeval

This commit is contained in:
Steffen Vogel 2011-11-22 01:48:45 +01:00
parent 0a44949239
commit 7649863508
2 changed files with 16 additions and 0 deletions

View file

@ -116,6 +116,14 @@ typedef struct {
*/
double tvtod(struct timeval tv);
/**
* Converts double to timeval structure
*
* @param ts the double value
* @return the timeval strucure
*/
struct timeval dtotv(double ts);
/**
* Get list of available meter types
*/

View file

@ -26,6 +26,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "meter.h"
#include "options.h"
@ -115,3 +116,10 @@ double tvtod(struct timeval tv) {
return tv.tv_sec + tv.tv_usec / 1e6;
}
struct timeval dtotv(double ts) {
struct timeval tv;
tv.tv_usec = modf(timestamp, &tv.tv_sec);
return tv;
}