summaryrefslogtreecommitdiffstats
path: root/contrib/libf2c/libU77/datetime_.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libf2c/libU77/datetime_.c')
-rw-r--r--contrib/libf2c/libU77/datetime_.c66
1 files changed, 38 insertions, 28 deletions
diff --git a/contrib/libf2c/libU77/datetime_.c b/contrib/libf2c/libU77/datetime_.c
index 62b06b6..cd7c7ca 100644
--- a/contrib/libf2c/libU77/datetime_.c
+++ b/contrib/libf2c/libU77/datetime_.c
@@ -31,40 +31,48 @@ Boston, MA 02111-1307, USA. */
# include <time.h>
# endif
#endif
+#if defined (_WIN32)
+#include <windows.h>
+#undef min
+#undef max
+#endif
#include "f2c.h"
-#ifdef KR_headers
-VOID s_copy ();
-#else
-void s_copy(register char *a, register char *b, ftnlen la, ftnlen lb);
-#endif
+void s_copy (register char *a, register char *b, ftnlen la, ftnlen lb);
-int G77_date_and_time_0 (char *date, char *fftime, char *zone,
- integer *values, ftnlen date_len,
- ftnlen fftime_len, ftnlen zone_len)
+int
+G77_date_and_time_0 (char *date, char *fftime, char *zone,
+ integer * values, ftnlen date_len,
+ ftnlen fftime_len, ftnlen zone_len)
{
- time_t lt=time(&lt);
- struct tm ltime = *localtime(&lt), gtime = *gmtime(&lt);
+ time_t lt = time (&lt);
+ struct tm ltime = *localtime (&lt), gtime = *gmtime (&lt);
char dat[9], zon[6], ftim[11];
int i, vals[8];
+#if defined (_WIN32)
+ struct _SYSTEMTIME wdattim;
+ GetLocalTime(&wdattim);
+ vals[7] = wdattim.wMilliseconds;
+#else
+ vals[7] = 0; /* no STDC/POSIX way to get this */
+ /* GNUish way; maybe use `ftime' on other systems. */
+#endif
vals[0] = 1900 + ltime.tm_year;
vals[1] = 1 + ltime.tm_mon;
vals[2] = ltime.tm_mday;
/* fixme: year boundaries */
vals[3] = (ltime.tm_min - gtime.tm_min +
- 60*(ltime.tm_hour - gtime.tm_hour +
- 24*(ltime.tm_yday -gtime.tm_yday)));
+ 60 * (ltime.tm_hour - gtime.tm_hour +
+ 24 * (ltime.tm_yday - gtime.tm_yday)));
vals[4] = ltime.tm_hour;
vals[5] = ltime.tm_min;
vals[6] = ltime.tm_sec;
- vals[7] = 0; /* no STDC/POSIX way to get this */
- /* GNUish way; maybe use `ftime' on other systems. */
#if HAVE_GETTIMEOFDAY
{
struct timeval tp;
# if GETTIMEOFDAY_ONE_ARGUMENT
- if (! gettimeofday (&tp))
+ if (!gettimeofday (&tp))
# else
# if HAVE_STRUCT_TIMEZONE
struct timezone tzp;
@@ -74,26 +82,28 @@ int G77_date_and_time_0 (char *date, char *fftime, char *zone,
HPUX. Configure checks if gettimeofday actually fails with a
non-NULL arg and pretends that struct timezone is missing if it
does fail. */
- if (! gettimeofday (&tp, &tzp))
+ if (!gettimeofday (&tp, &tzp))
# else
- if (! gettimeofday (&tp, (void *) 0))
+ if (!gettimeofday (&tp, (void *) 0))
# endif /* HAVE_STRUCT_TIMEZONE */
# endif /* GETTIMEOFDAY_ONE_ARGUMENT */
- vals[7] = tp.tv_usec/1000;
+ vals[7] = tp.tv_usec / 1000;
}
#endif /* HAVE_GETTIMEOFDAY */
if (values) /* null pointer for missing optional */
- for (i=0; i<=7; i++)
+ for (i = 0; i <= 7; i++)
values[i] = vals[i];
sprintf (dat, "%04d%02d%02d", vals[0], vals[1], vals[2]);
- s_copy(date, dat, date_len, 8);
- if (zone) {
- sprintf(zon, "%+03d%02d", vals[3] / 60, abs(vals[3] % 60));
- s_copy(zone, zon, zone_len, 5);
- }
- if (fftime) {
- sprintf (ftim, "%02d%02d%02d.%03d", vals[4], vals[5], vals[6], vals[7]);
- s_copy(fftime, ftim, fftime_len, 10);
- }
+ s_copy (date, dat, date_len, 8);
+ if (zone)
+ {
+ sprintf (zon, "%+03d%02d", vals[3] / 60, abs (vals[3] % 60));
+ s_copy (zone, zon, zone_len, 5);
+ }
+ if (fftime)
+ {
+ sprintf (ftim, "%02d%02d%02d.%03d", vals[4], vals[5], vals[6], vals[7]);
+ s_copy (fftime, ftim, fftime_len, 10);
+ }
return 0;
}
OpenPOWER on IntegriCloud