summaryrefslogtreecommitdiffstats
path: root/helloworld.c
blob: be8fd700c777c92245f805a558def3fdd828ff07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* helloworld.c: A program to show the time since the Epoch */
 
#include <stdio.h>
#include "config.h"
 
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#else
#include <time.h>
#endif
 
double get_sec_since_epoch()
{
   double sec;
 
   #ifdef HAVE_GETTIMEOFDAY
      struct timeval tv;
 
      gettimeofday(&tv, NULL);
      sec = tv.tv_sec;
      sec += tv.tv_usec / 1000000.0;
   #else
      sec = time(NULL);
   #endif
 
   return sec;
}
 
int main(int argc, char* argv[])
{
   printf("hello, world! epoch is: ");
   printf("%f\n", get_sec_since_epoch());
 
   return 0;
}