added function to convert double to struct timeval
This commit is contained in:
parent
0a44949239
commit
7649863508
2 changed files with 16 additions and 0 deletions
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue