Jspice3
time.c File Reference
#include "spice.h"
#include "misc.h"
Include dependency graph for time.c:

Go to the source code of this file.

Functions

char * datestring ()
 
double seconds ()
 

Function Documentation

char* datestring ( )

Definition at line 37 of file time.c.

39 {
40 
41 #if defined(HAVE_GETTIMEOFDAY) || defined(HAVE_TIMES)
42  struct tm *tp;
43  static char tbuf[40];
44  char *ap;
45  int i;
46 #ifdef HAVE_GETTIMEOFDAY
47  struct timeval tv;
48  struct timezone tz;
49 
50  (void) gettimeofday(&tv, &tz);
51  tp = localtime(&tv.tv_sec);
52  ap = asctime(tp);
53 #else
54  long tloc;
55 
56  time(&tloc);
57  tp = localtime(&tloc);
58  ap = asctime(tp);
59 #endif
60 
61  strcpy(tbuf,ap);
62  i = strlen(tbuf);
63  tbuf[i - 1] = '\0';
64  return (tbuf);
65 
66 #else
67 
68  return ("today");
69 
70 #endif
71 }
char * strcpy()
double seconds ( )

Definition at line 103 of file time.c.

105 {
106 #ifdef MSDOS
107  unsigned long tics = (unsigned long)dos_tics();
108  return ((double) tics*0.054945); /* 1/18.2 */
109 #else
110 #ifdef HAVE_GETTIMEOFDAY
111  struct timeval tv;
112  struct timezone tz;
113 
114  (void) gettimeofday(&tv, &tz);
115  return
116  (tv.tv_sec + (double) tv.tv_usec / 1000000.0);
117 #else
118 #ifdef HAVE_FTIME
119  struct timeb timenow;
120  int sec, msec;
121 
122  ftime(&timenow);
123  timediff(&timenow, &timebegin, &sec, &msec);
124  return (sec + (double) msec / 1000.0);
125 #else
126 #ifdef HAVE_VMSHACK
127  return ((double)clock()/(double)CLK_TCK);
128 #else /* unknown */
129  /* don't know how to do this in general. */
130  return (-1.0); /* Obvious error condition */
131 #endif /* !VMS */
132 #endif /* !FTIME */
133 #endif /* !BSD */
134 #endif /* DOS */
135 
136 }