From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 10-SEP-1990 18:47:54.97
To:	MRGATE::"ARISIA::EVERHART"
CC:	
Subj:	Re: VMS Time format

Received:  by crdgw1.ge.com (5.57/GE 1.70)
	 id AA14660; Mon, 10 Sep 90 18:31:21 EDT
Received: From DANPOST.UNI-C.DK by CRVAX.SRI.COM with TCP; Mon, 10 SEP 90 15:23:14 PDT
Received: from vms2.uni-c.dk by danpost.uni-c.dk (5.61/4.7)
	id AA17164; Mon, 10 Sep 90 22:16:34 GMT
Date: Tue, 11 Sep 90 00:20 +0200
From: ISIS08@ecostat.aau.dk
Subject: Re: VMS Time format
To: INFO-VAX@SRI.COM, MLEVIN@TUFTS.BITNET
Message-Id: <377BABC459DF21AE66@vms2.uni-c.dk>
X-Envelope-To: INFO-VAX@SRI.COM, MLEVIN@TUFTS.BITNET
X-Vms-To: IN::"INFO-VAX@SRI.COM",IN::"MLEVIN@TUFTS.BITNET"

> Does anyone know how to convert between the 64-bit binary time
> format used in VMS system services and the Unix-style unsigned
> format which the VAX C function stat() gives for files (and vice versa)?
> The unsigned format is mentioned nowhere in the VMS manuals;
> how does stat() do it? Thanks in advance.

The unsigned format used by fstat is the standard UNIX time
(number of seconds since 1-JAN-1970 00:00:00).

It is quite simple to convert between the two formats:

        .title  timecvt
;
;  unixtime=vms2unix(vmstime)
;
        .entry  vms2unix,^m<>
        movq    @B^4(ap),r0
        subl2   #^x4BEB4000,r0
        sbwc    #^x007C9567,r1
        ediv    #10000000,r0,r0,r1
        ret
;
;  unix2vms(unixtime,vmstime)
;
        .entry  unix2vms,^m<>
        emul    @B^4(ap),#10000000,#0,r0
        addl2   #^x4BEB4000,r0
        adwc    #^x007C9567,r1
        movq    r0,@B^8(ap)
        ret
;
        .end
                                                     
Note, that VMS2UNIX not is exact, since you can not represent 64 bit
in 32 bit !!!!

                                                             Arne

Arne Vajhxj                             Internet: ISIS08@ECOSTAT.AAU.DK
Institute of Economics and Statistics   PSI:      DATAPAX.23830211371400::ISIS08
Aarhus University
Denmark


