From:	CSBVAX::CSBVAX::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 17-FEB-1989 19:04
To:	MRGATE::"ARISIA::EVERHART"
Subj:	CVTIME_SHARE /SUBJ="CORRECTED 1/1


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Fri, 17 FEB 89 13:54:52 PDT
Received: from rutgers.edu by KL.SRI.COM with TCP; Fri, 17 Feb 89 13:56:24 PST
Received: from mcnc.mcnc.org by rutgers.edu (5.59/SMI4.0/RU1.1/3.03) 
	id AA10091; Fri, 17 Feb 89 16:17:54 EST
Received: by mcnc.mcnc.org (5.59/MCNC/5-16-88)
	id AA28527; Fri, 17 Feb 89 16:17:35 EST
Received: by ge-rtp.GE.COM (4.12/UUCP-Project/1.0/ge-rtp.GE.COM/1.8)
	id AA00449; Fri, 17 Feb 89 09:40:40 est
Date: Fri, 17 Feb 89 09:40:40 est
Message-Id: <8902171440.AA00449@ge-rtp.GE.COM>
From: rlb@rtpark.ge.com (Bob Boyd 8*565-3627  17-Feb-1989 0944)
To: info_vax@mcnc.org
Subject: CVTIME_SHARE /SUBJ="CORRECTED 1/1

$! ................... Cut between dotted lines and save. ...................
$!...........................................................................
$! VAX/VMS archive file created by VMS_SHARE V06.10 7-FEB-1989.
$!
$! VMS_SHARE was written by James Gray (Gray:OSBUSouth@Xerox.COM) from
$! VMS_SHAR by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au).
$!
$! To unpack, simply save, concatinate all parts into one file and
$! execute (@) that file.
$!
$! This archive was created by user RLB
$! on 17-FEB-1989 09:43:37.22.
$!
$! It contains the following 1 file:
$!        CVTIME.COM
$!
$!============================================================================
$ SET SYMBOL/SCOPE=( NOLOCAL, NOGLOBAL )
$ VERSION = F$GETSYI( "VERSION" )
$ IF VERSION .GES "V4.4" THEN GOTO VERSION_OK
$ WRITE SYS$OUTPUT "You are running VMS ''VERSION'; ", -
    "VMS_SHARE V06.10 7-FEB-1989 requires VMS V4.4 or higher."
$ EXIT 44 ! SS$_ABORT
$VERSION_OK:
$ GOTO START
$!
$UNPACK_FILE:
$ WRITE SYS$OUTPUT "Creating ''FILE_IS'"
$ DEFINE/USER_MODE SYS$OUTPUT NL:
$ EDIT/TPU/COMMAND=SYS$INPUT/NODISPLAY/OUTPUT='FILE_IS'/NOSECTION -
    VMS_SHARE_DUMMY.DUMMY
b_part := CREATE_BUFFER( "{Part}", GET_INFO( COMMAND_LINE, "file_name" ) )
; s_file_spec := GET_INFO( COMMAND_LINE, "output_file" ); SET( OUTPUT_FILE
, b_part, s_file_spec ); b_errors := CREATE_BUFFER( "{Errors}" ); i_errors 
:= 0; pat_beg_1 := ANCHOR & "-+-+-+ Beginning"; pat_beg_2 := LINE_BEGIN 
& "+-+-+-+ Beginning"; pat_end := ANCHOR & "+-+-+-+-+ End"; POSITION
( BEGINNING_OF( b_part ) ); LOOP EXITIF SEARCH( SPAN( ' ' )@r_trail 
& LINE_END, FORWARD) = 0; POSITION( r_trail ); ERASE( r_trail ); ENDLOOP
; POSITION( BEGINNING_OF( b_part ) ); i_append_line := 0; LOOP EXITIF MARK
( NONE ) = END_OF( b_part ); s_x := ERASE_CHARACTER( 1 )
; IF s_x = '+' THEN r_skip := SEARCH( pat_beg_1, FORWARD, EXACT ); IF r_skip 
<> 0 THEN s_x := ''; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ERASE_LINE; ENDIF
; ENDIF; IF s_x = '-' THEN r_skip := SEARCH( pat_end, FORWARD, EXACT )
; IF r_skip <> 0 THEN s_x := ''; MOVE_HORIZONTAL( -CURRENT_OFFSET ); m_skip 
:= MARK( NONE ); r_skip := SEARCH( pat_beg_2, FORWARD, EXACT ); IF r_skip 
<> 0 THEN POSITION( END_OF( r_skip ) ); MOVE_HORIZONTAL( -CURRENT_OFFSET )
; MOVE_VERTICAL( 1 ); MOVE_HORIZONTAL( -1 ); ELSE POSITION( END_OF( b_part ) 
); ENDIF; ERASE( CREATE_RANGE( m_skip, MARK( NONE ), NONE ) ); ENDIF; ENDIF
; IF s_x = 'V' THEN s_x := ''; IF i_append_line <> 0 THEN APPEND_LINE
; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF; i_append_line := 1
; MOVE_VERTICAL( 1 ); ENDIF; IF s_x = 'X' THEN s_x := ''; IF i_append_line 
<> 0 THEN APPEND_LINE; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF
; i_append_line := 0; MOVE_VERTICAL( 1 ); ENDIF; IF s_x <> '' THEN i_errors 
:= i_errors + 1; s_text := CURRENT_LINE; POSITION( b_errors ); COPY_TEXT
( "The following line could not be unpacked properly:" ); SPLIT_LINE
; COPY_TEXT( s_x ); COPY_TEXT( s_text ); POSITION( b_part ); MOVE_VERTICAL
( 1 ); ENDIF; ENDLOOP; POSITION( BEGINNING_OF( b_part ) ); LOOP r_x := SEARCH
( "`", FORWARD, EXACT ); EXITIF r_x = 0; POSITION( r_x ); ERASE_CHARACTER( 1 
); COPY_TEXT( ASCII( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDLOOP
; IF i_errors = 0 THEN SET( NO_WRITE, b_errors, ON ); ELSE POSITION
( BEGINNING_OF( b_errors ) ); COPY_TEXT( FAO
( "The following !UL errors were detected while unpacking !AS", i_errors
, s_file_spec ) ); SPLIT_LINE; SET( OUTPUT_FILE, b_errors, "SYS$COMMAND" )
; ENDIF; EXIT; 
$ DELETE VMS_SHARE_DUMMY.DUMMY;*
$ CHECKSUM 'FILE_IS
$ WRITE SYS$OUTPUT " CHECKSUM ", -
  F$ELEMENT( CHECKSUM_IS .EQ. CHECKSUM$CHECKSUM, ",", "failed!!,passed." )
$ RETURN
$!
$START: 
$ FILE_IS = "CVTIME.COM"
$ CHECKSUM_IS = 2085105392
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$ vfl = f$VERIFY(0)
X$! do LASTMONTH, NEXTMONTH, THISYEAR, NEXTYEAR, LASTYEAR
X$! p1 -- keyword`032
X$! p2 -- global symbol to pass value to
X$! p3 -- target date to use as input
X$ p3 = f$cvtime(p3,"absolute","date")
V$ VALID_KEYWORDS = ",THISMONTH,LASTMONTH,NEXTMONTH,THISYEAR,NEXTYEAR,LASTYEAR
X"
X$ valid_keywords = valid_keywords+",THISWEEK,NEXTWEEK,LASTWEEK"
X$ if f$LOC(","+p1,valid_keywords).lt.f$LEN(valid_keywords) then $ goto 'p1'
X$ write sys$output "%CVTIME-E-INVKEYWORD, ",p1," is an invalid keyword"
X$ exit "%X00038060"
X$NEXTMONTH:
X$ if p3.nes."" then $ p3 = f$cvtime(p3,"absolute","MONTH")
X$ time = f$CVTIME("1-"+p3+"-"+"+32-0","ABSOLUTE","DATE")
V$ time = "1-"+f$cvtime(time,"absolute","month")+"-"+f$cvtime(time,"absolute",
X"year")
X$ goto exit
X$THISMONTH:
X$ if p3.nes."" then $ p3 = f$cvtime(p3,"absolute","MONTH")
X$ time = f$CVTIME("1-"+p3+"-","ABSOLUTE","DATE")
X$ goto exit
X$LASTMONTH:
X$ if p3.nes."" then $ p3 = f$cvtime(p3,"absolute","MONTH")
X$ last_month = "1-"+p3+"-:-1-0:"
X$ time = "1-"+f$CVTIME(last_month,"ABSOLUTE","MONTH")+"-"+ -
X`009f$CVTIME(last_month,"ABSOLUTE","YEAR")
X$ goto exit
X$LASTYEAR:
X$ if p3.nes."" then $ p3 = f$cvtime(p3,"absolute","year")
X$ last_year = "1-JAN-"+p3+":-1-0:"
X$ time = "1-JAN-"+f$CVTIME(last_year,"ABSOLUTE","YEAR")
X$ goto exit
X$THISYEAR:
X$ if p3.nes."" then $ p3 = f$cvtime(p3,"absolute","YEAR")
X$ time = f$CVTIME("1-JAN-"+p3,"ABSOLUTE","DATE")
X$ goto exit
X$NEXTYEAR:
X$ if p3.nes."" then $ p3 = f$cvtime(p3,"absolute","YEAR")
X$ time = f$CVTIME("31-DEC-"+p3+":+1-0:","ABSOLUTE","DATE")
X$ goto exit
X$EXIT:
X$ if p2.nes."" then $ 'p2' == time
X$ if p2.eqs."" then $ write sys$output "CVTIME: ",p1," = ",time
X$ exit !'f$VER(vfl)'
X$THISWEEK: ! Monday is beginning of week
X$ sunday = 6
X$ monday = 0
X$ tuesday = 1
X$ wednesday = 2
X$ thursday = 3
X$ friday = 4
X$ saturday = 5
X$ today = 'f$CVTIME(p3,,"WEEKDAY")'
X$ time = f$CVTIME(p3+":0:0:0.0-"+f$STRING(today)+"-0:","ABSOLUTE","DATE")
X$ goto exit
X$NEXTWEEK: ! Monday is beginning of week
X$ sunday = 6
X$ monday = 0
X$ tuesday = 1
X$ wednesday = 2
X$ thursday = 3
X$ friday = 4
X$ saturday = 5
X$ today = 7-'f$CVTIME(p3,,"WEEKDAY")'
X$ time = f$CVTIME(p3+":0:0:0.0+"+f$STRING(today)+"-0:","ABSOLUTE","DATE")
X$ goto exit
X$LASTWEEK: ! Monday is beginning of week
X$ sunday = 6
X$ monday = 0
X$ tuesday = 1
X$ wednesday = 2
X$ thursday = 3
X$ friday = 4
X$ saturday = 5
X$ today = 7+'f$CVTIME(p3,,"WEEKDAY")'
X$ time = f$CVTIME(p3+":0:0:0.0-"+f$STRING(today)+"-0:","ABSOLUTE","DATE")
X$ goto EXIT
X$!Last Modified:  17-FEB-1989 09:28:13.91, By: RLB`032
$ GOSUB UNPACK_FILE
$ EXIT

