/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>

#include <timeb.h>

#include <starlet.h>

#define SECS_PER_HOUR (60 * 60)
#define SECS_PER_DAY (24 * SECS_PER_HOUR)
#define TZ_DIF 2 /* please adjust carefull */

/* C RTL */
int msec1()
{
   struct timeb t;
   ftime(&t);
   return (1000 * (t.time % SECS_PER_DAY) + t.millitm);
}

/* VMS System Service (note: use of 64 bit integer) */
int msec2()
{
   __int64 t;
   sys$gettim(&t);
   t = t / 10000; /* VMS time units -> milliseconds */
   return ((t - 1000 * TZ_DIF * SECS_PER_HOUR) % (1000 * SECS_PER_DAY));
}

int main()
{
   printf("%d\n",msec1());
   printf("%d\n",msec2());
   printf("%d\n",msec1());
   printf("%d\n",msec2());
}
