Decoding the VMS 64bit timestamp... 
Author Message
 Decoding the VMS 64bit timestamp...

I need to decode VMS's 64bit timestamp. Does anyone have a snippet of
C/C++ code which will help me do this.

Ideally I want to be able to compare two VMS times together to see
which came first etc.

Cheers
Mark.

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 04 Aug 2002 03:00:00 GMT  
 Decoding the VMS 64bit timestamp...

Quote:

> I need to decode VMS's 64bit timestamp. Does anyone have a snippet of
> C/C++ code which will help me do this.

> Ideally I want to be able to compare two VMS times together to see
> which came first etc.

Comparing is easy, compare the top 32-bits. Only if they are the same,
compare the lower 32-bits.

Paul



Sun, 04 Aug 2002 03:00:00 GMT  
 Decoding the VMS 64bit timestamp...

Quote:

> I need to decode VMS's 64bit timestamp. Does anyone have a snippet of
> C/C++ code which will help me do this.

> Ideally I want to be able to compare two VMS times together to see
> which came first etc.

The format is a monatonically increasing number, so just declare
it as a 64-bit unsigned number (however you say that in C) and
compare.


Sun, 04 Aug 2002 03:00:00 GMT  
 Decoding the VMS 64bit timestamp...
VMS's absolute time format is a simple 64-bit integer.
Just do a quadword compare; you don't need to decode
anything.

Quote:

> I need to decode VMS's 64bit timestamp. Does anyone have a snippet of
> C/C++ code which will help me do this.

> Ideally I want to be able to compare two VMS times together to see
> which came first etc.

> Cheers
> Mark.

> Sent via Deja.com http://www.deja.com/
> Before you buy.

--
norm lastovica / oracle rdb engineering / usa / 603.897.3505



Sun, 04 Aug 2002 03:00:00 GMT  
 Decoding the VMS 64bit timestamp...

:I need to decode VMS's 64bit timestamp.

  When posting, please include the platform and version of OpenVMS and
  of relevent products -- without this, I may well point you to system
  calls or such that your particular OpenVMS or Compaq C version does
  not yet have...  Thanks!

:Does anyone have a snippet of C/C++ code which will help me do this.

  Absolute times are positive quadword values, while delta times are
  negative values.  (__int64, or unsigned long int x[2], depending on
  the OpenVMS platform and C version...)

:Ideally I want to be able to compare two VMS times together to see
:which came first etc.

  Among the easiest approaches is a call to $numtim (which will handle
  absolute and delta formats), followed by a comparision of the seven
  items returned in the array...

  If you have or can convert the times into two absolute times, then
  comparison (quadword comparison if available, or high longword and
  then if needed low longword) is quite easy...

 --------------------------- pure personal opinion ---------------------------
   Hoff (Stephen) Hoffman   OpenVMS Engineering   hoffman#xdelta.zko.dec.com



Sun, 04 Aug 2002 03:00:00 GMT  
 Decoding the VMS 64bit timestamp...

Quote:

}I need to decode VMS's 64bit timestamp. Does anyone have a snippet of
}C/C++ code which will help me do this.
}
}Ideally I want to be able to compare two VMS times together to see
}which came first etc.
}
}Cheers
}Mark.

They are just plain old 64 bit signed integers. Any "time stamp" ought
to be a positive integer since negatives are delta times, not specific
date-times.

So put them in 64 bit signed integers and compare them. The bigger one is
the newest one. The difference is the number of 100 nanosecond intervals
between the two.

--- Carl



Sun, 04 Aug 2002 03:00:00 GMT  
 Decoding the VMS 64bit timestamp...

Quote:

> I need to decode VMS's 64bit timestamp. Does anyone have a snippet of
> C/C++ code which will help me do this.

> Ideally I want to be able to compare two VMS times together to see
> which came first etc.

> Cheers
> Mark.

> Sent via Deja.com http://www.deja.com/
> Before you buy.

There are library functions which accomplish your tasks.  You really
ought not to spend time reinventing the wheel.

Jim



Sun, 04 Aug 2002 03:00:00 GMT  
 Decoding the VMS 64bit timestamp...
Thanks norm,
Thanks norm,
   Do you know how I can convert this VMS time into a string
representation, ie 20000217121645 ( 17th Feb 2000 12:16:45 )

I'm going to be doing this on NT so I won't have any access to sys$....
calls

Cheers
Mark



Quote:
> VMS's absolute time format is a simple 64-bit integer.
> Just do a quadword compare; you don't need to decode
> anything.


> > I need to decode VMS's 64bit timestamp. Does anyone have a snippet
of
> > C/C++ code which will help me do this.

> > Ideally I want to be able to compare two VMS times together to see
> > which came first etc.

> > Cheers
> > Mark.

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

> --
> norm lastovica / oracle rdb engineering / usa / 603.897.3505


Sent via Deja.com http://www.deja.com/
Before you buy.


Mon, 05 Aug 2002 03:00:00 GMT  
 Decoding the VMS 64bit timestamp...

Quote:

>    Do you know how I can convert this VMS time into a string
> representation, ie 20000217121645 ( 17th Feb 2000 12:16:45 )

        Just call the SYS$ASCTIM system service and juggle the results.

Quote:
> I'm going to be doing this on NT so I won't have any access to sys$....
> calls

Oh, then do one of:

   1)   Just write your own equivalent of the SYS$ASCTIM system service.
        The 64-bit number is a count of 100 nanosecond intervals.

   2)   Perform the conversion on the VMS system and transmit ASCII.

   3)   Give up on NT and do the whole thing on VMS.



Mon, 05 Aug 2002 03:00:00 GMT  
 Decoding the VMS 64bit timestamp...
If you need to convert between UNIX and VMS time, let me know.  I have
code for that around here somewhere...

--
#include <standard.disclaimer>
 _
Kevin D Quitt  USA 91351-4454           96.37% of all statistics are made up
Per the FCA, this email address may not be added to any commercial mail list



Mon, 05 Aug 2002 03:00:00 GMT  
 Decoding the VMS 64bit timestamp...
/*      timecvt.c        9-Apr-97 15:30:04 by Kevin D. Quitt

        u2vtime         Convert UNIX seconds to VMS clunks.
        v2utime         Convert VMS clunks to UNIX seconds

Unix time is a 32-bit count of seconds after midnight, January 1, 1970.

VMS time is a 64-bit count of 100 ns intervals since midnight, November
17, 1858

NOTE:   These routines do NOT accomodate leap seconds that have been
inserted
        for calendar accuracy.
*/

#define HIW(x)  ((unsigned int)(((x) >> 16) & 0xFFFF))
#define LOW(x)  ((unsigned int)( (x)        & 0xFFFF))

/*  Delta is the number of seconds from 17-Nov-1858 to 1-Jan-1970
    Scale converts between seconds and clunks (100ns)

#define DELTA   ((unsigned long long)3538252800L)
#define SCALE   ((unsigned long)10000000L)
*/
#define SCALE1  ((unsigned short)10000)
#define SCALE2  ((unsigned short)1000)

#define DELTAH  (0xD2E5)
#define DELTAL  (0x7400)

static unsigned short   Delta[4]    = { DELTAL, DELTAH, 0, 0 };

/*  Full 64+64 bit add
*/
static int  add( from, to )
    unsigned short *from, *to;
  {
    unsigned int    partial, i;

    for ( i = 0; i < 4; i++ )
      {
        partial = from[ i ] + to[ i ];
        to[ i ] = LOW(partial);
        partial = HIW(partial);
      }
  }

/*  64-64 bit subtract
*/
static int  subtract( diminuend, subtrahend )
    unsigned short *diminuend, *subtrahend;
  {
    unsigned int    partial, i, j;

    for ( i = 0; i < 2; i++ )
      {
        partial = subtrahend[ i ];
        if ( subtrahend[ i ]  <  diminuend[ i ] )
          {
            for ( j = i + 1; j < 3 ; j++ )
              {
                if ( --subtrahend[ i ]  !=  (unsigned short)0xFFFF )
                    break;
              }
            partial += 0x10000;
          }

        partial -= diminuend[ i ];

        subtrahend[ i ] = LOW(partial);
      }
  }

/*  64*16 bit multiply
*/
static int  multiply( multiplier, multiplicand )
    unsigned short multiplier, *multiplicand;
  {
    unsigned int    partial, carry, i;

    carry   = 0;

    for ( i = 0; i < 4; i++ )
      {
        partial = multiplicand[ i ];
        partial = partial * multiplier + carry;

        multiplicand[ i ]   = LOW(partial);
        carry               = HIW(partial);
      }
  }

/*  64/16 bit divide
*/
static int  divide( divisor, dividend )
    unsigned short divisor, *dividend;
  {
    unsigned int    partial, borrow, i;

    borrow;

    for ( i = 3; i >-1; i-- )
      {
        partial         = (borrow << 16) + dividend[ i ];

        borrow          = partial % divisor;
        dividend[ i ]   = partial / divisor;
      }
  }

/*  Clunks are:     SCALE * (seconds + DELTA)
*/

int u2vtime( seconds, clunk )
    unsigned int seconds; unsigned short *clunk;
  {

    clunk[ 0 ]  = LOW( seconds );
    clunk[ 1 ]  = HIW( seconds );

    add( Delta, clunk );
    multiply( SCALE1, clunk );
    multiply( SCALE2, clunk );
  }

/*    Seconds are:    clunks / SCALE - DELTA
*/

unsigned int    v2utime( clunk )
    unsigned short *clunk;
  {
    unsigned int    seconds;

    divide( SCALE1, clunk );
    divide( SCALE2, clunk );
    subtract( Delta, clunk );

    seconds = clunk[ 1 ];
    seconds = (seconds << 16) + clunk[ 0 ];

    return  seconds;
  }

--
#include <standard.disclaimer>
 _
Kevin D Quitt  USA 91351-4454           96.37% of all statistics are made up
Per the FCA, this email address may not be added to any commercial mail list



Mon, 05 Aug 2002 03:00:00 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. 64bit platform and atomic data type

2. 64bit arithematic

3. 64bit arithmatic

4. signed 64bit (aka 32:32 bit) pseudo division and multiplication

5. ANSI C implementation to display 64bit number in decimal

6. Modulus fucntion needed for 64bit integers

7. Example on 64bit division using C

8. looking for a 64bit math library

9. 64bit Integer Arithmetic

10. 80bit double from mac to 64bit double to pc

11. signed int 64bit class library?

12. printf with 64bit int - how?

 

 
Powered by phpBB® Forum Software