Everhart, Glenn From: LC's No-Spam Newsreading account [nospam@ifctr.mi.cnr.it] Sent: Monday, May 18, 1998 10:56 AM To: Info-VAX@Mvb.Saic.Com Subject: Re: Smithsonian base date conversion capgemin@eutelsat.fr writes... > : > >To do so I need to know the delta time in seconds between the VMS base time > >(the Smithsonian base date 00:00, 17th November 1858) and the unix base time > >(00:00:00 GMT 1 Jan 1970). Can anyone of you provide this 'magic' number ? I've lost the beginning of this thread. I just know that when I had to write s/w for a project which had to be portable on Unix and VMS, I elected the Unix time as my internal standard. For instance the following (set of) routines return the current time, passing trhough a time array FUNCTION ZC_TIME() INTEGER ZC_TIME C---------------------------------------------------------------------- C C.IDENTIFICATION: INTEGER Function ZC_TIME C.LIBRARY: VOS (experimental version) C.AUTHOR: L.Chiappetti - IFCTR Milano C.VERSIONS: 0.0 - 24 Sep 92 - Test version (VMS) C C.PURPOSE: return current time C.METHOD: call SYS$GETTIM and then convert to C more manageable time units C C.SYNTAX: TIME = ZC_TIME() C.PARAMETERS: none C returns time in seconds since 1970 C.RESTRICTIONS: C.NOTES: C.FILES: none C.REFERENCES: SYS$GETTIM and NUMTIM, TIME_1970 C C---------------------------------------------------------------------- C INTEGER I,K,SYS$GETTIM,SYS$NUMTIM INTEGER*2 TIMES(7) INTEGER ITIME(7),TIME INTEGER*4 QUADWD(2) INCLUDE 'voscommon.inc' INCLUDE 'errors.inc' C INCLUDE '($SSDEF)' if testing errors is desired C C C derive the time in VAX quadword C VOSCOMMON_SYSTEMERROR=SYS$GETTIM(QUADWD) K=SYS$NUMTIM(TIMES,QUADWD) C convert to seconds from 1970 for Unix compatibility DO 20 I=1,7 ITIME(I)=TIMES(I) 20 CONTINUE CALL TIME_1970(ITIME,TIME) ZC_TIME=TIME C C error policy (VMS success is 1 , NB !) is provisional C IF(VOSCOMMON_SYSTEMERROR.NE.1)VOSCOMMON_ERROR=9999 RETURN END SUBROUTINE TIME_1970(ITIME,I70) C C---------------------------------------------------------------------- C C.IDENTIFICATION: Subroutine TIME_1970 C.LIBRARY: GENERAL C.AUTHOR: L.Chiappetti - IFCTR Milano C.VERSIONS: 1.0 - 27 Aug 92 - Original version C.PURPOSE: convert time array (y m d h m s f) to sec since 1970 C.METHOD: arithmetics C.SYNTAX: CALL TIME_1970(ITIME,I70) C.PARAMETERS: INTEGER ITIME(7) time array (input) C INTEGER I70 seconds since 1970 (output) C.RESTRICTIONS: valid to year 2038 because of INTEGER*4 (signed) C.NOTES: does NOT check legal range of year, month etc. C does NOT consider leap seconds C.FILES: none C.REFERENCES: noen C C---------------------------------------------------------------------- C INTEGER ITIME(7),I70,IJD,MONTHS(12),IYE LOGICAL LEAP C C offset for Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec DATA MONTHS / 0, 31, 59, 90,120,151,181,212,243,273,304,334/ C C compute elapsed years since 1970 IYE=ITIME(1)-1970 C-> if year is less than 1970 or greater than ???? should give error C-> also if month is illegal (not 1-12) or day is illegal ... C C handle elapsed days in entire years since 1970 jan 1 0:0:0 C correction term is for leap years since 1970 (2000 is not leap) C extra correction for years > 2000 : OK up to 2400 IJD=IYE*365 + (IYE+1)/4 IF(ITIME(1).GT.2000)IJD=IJD-1 C C is it a leap year (every 4 but not 1700. 1800. etc. but 1600 and 2000 yes) C LEAP = (MOD(ITIME(1),4).EQ.0.AND.MOD(ITIME(1),100).NE.0).OR.MOD(ITIME(1),400).EQ.0 C however in range 1970-2038 all years/4 are leap LEAP = MOD(ITIME(1),4).EQ.0 C C compute day of the year and add it IJD=IJD+ITIME(3)+MONTHS(ITIME(2)) IF (LEAP.AND.ITIME(2).GT.2)IJD=IJD+1 C C handle elapsed days in the year and convert to seconds I70=(IJD-1)*86400 C C handle hours minutes seconds (ignore fraction of seconds) I70=I70+ITIME(6)+ITIME(5)*60+ITIME(4)*3600 C C shall one take into account leap seconds too ? RETURN END ---------------------------------------------------------------------- nospam@ifctr.mi.cnr.it is a newsreading account used by more persons to avoid unwanted spam. Any mail returning to this address will be rejected. Users can disclose their e-mail address in the article if they wish so.