[an error occurred while processing this directive]

HP OpenVMS Systems

ask the wizard
Content starts here

High-precision time values?

» close window

The Question is:

 
How to get gmt time with
 a.microsecond precision.
and taking care of Day light saving.
i.e. similar gmtime function in vms version 7.2.
 
 


The Answer is :

 
  Not without external assistance -- the OpenVMS time displays will
  generally operate at centisecond resolution.
 
  If the resolution of the existing UTC services is insufficient, you
  could consider using the Alpha System Cycle Counter (SCC) -- see
  below -- or the use of external hardware.
 
  Daylight savings time change-overs can also be handled via the Compaq
  C run-time library, via the existing native quadword and UTC system
  service calls, or other similar interface.
 
  Alternatively, please contact the customer support center for
  assistance.
 
 
/*
**  This program demonstrates the usage of the Alpha System Cycle
**  Counter (SCC) register.
*/
#include <stdio.h>
#include <signal.h>
#include <hwrpbdef.h>
#include <evx_opcodes.h>
#include <c_asm.h>
 
#define QUOTE(s) #s
#define QUOTEVAL(s) QUOTE(s)
#define RSCC() (asm("call_pal " QUOTEVAL(EVX$PAL_RSCC)))
 
extern HWRPB* exe$gpq_hwrpb;  /* Hardware Restart Parameter Block */
 
int main (int argc, char** argv)
  {
  __int64 scc1, scc2, micro;
 
  scc1 = RSCC();
  sleep (3);
  scc2 = RSCC();
 
  /*
  ** The number of ticks per second is located in the HWRPB.
  ** Convert this value to microseconds.
  */
 
  micro = (1000000 * (scc2 - scc1)) /
    exe$gpq_hwrpb->hwrpb$iq_cycle_count_freq;
 
  printf ("%Ld microseconds\n", micro);
  }
 

answer written or last revised on ( 19-NOV-1999 )

» close window