[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference noted::hackers_v1

Title:-={ H A C K E R S }=-
Notice:Write locked - see NOTED::HACKERS
Moderator:DIEHRD::MORRIS
Created:Thu Feb 20 1986
Last Modified:Mon Aug 03 1992
Last Successful Update:Fri Jun 06 1997
Number of topics:680
Total number of notes:5456

535.0. "calendar arithmetic" by WMVAXC::MAX_BRIDGE () Fri Aug 21 1987 15:37

    
    There must be numerous versions of date conversion routines
    that use sys$bintim to get a quadword date, perform some
    date arithmetic (e.g. subtract 5 days ( 5 * 86400 )) and
    sys$asctim to reformat to get dd-mmm-yyyy. 
    
    I have searched this note file and sw_tools for a copy.
    This type of calendar arithmetic should be posted somewhere?
    
                                   
    Or I'll write it again....
T.RTitleUserPersonal
Name
DateLines
535.1CADSYS::SLATERKen SlaterFri Aug 21 1987 16:269
    In VMS V5.0, the RTL will provide extensive date manipulation functions.
    
    In the meantime, folks have been using LIB$ADDX, LIB$SUBX and LIB$EMUL
    to do things like you are asking for. I am not aware of any posted
    routines to do this.
    
    If you want to know more about the V5 routines, look at
    in BULOVA""::DOCD$:[50REVIEW.LPRDOC]NEWF_RTL_AX.LPR
    
535.2NOTEFILE ERRDREAMN::LORADITCHSeems like the nothing, never wasFri Aug 21 1987 20:475
    RE: .1
    
    INVALID FORMAT FOR NOTEFILE
    
    WHEN OPENING NEWF_RTL_AX.LPR
535.3NRADM2::MAXMGRAl CoteFri Aug 21 1987 23:427

It's an ASCII file containing documentation... try:

	$ COPY BULOVA""::DOCD$:[50REVIEW.LPRDOC]NEWF_RTL_AX.LPR []A.A
	$ PRINT A.A

535.4BMT::KOZAKIEWICZYou can call me Al...Tue Aug 25 1987 16:566

If you can't wait for V5, I have some MACRO routines, callable from FORTRAN
(or any VAX language), which do some date arithmetic and logical functions.
They should be real easy to clone to get the functionality you want if it is
different from what I have.  Let me know and I will be happy to post them here.
535.5Don't call me BettyDREAMN::LORADITCHSeems like the nothing, never wasWed Aug 26 1987 19:327
    re: .4
    
    Thanks Al, I'd appreciate a posting.
    
   
        
    
535.6BMT::KOZAKIEWICZYou can call me Al...Mon Aug 31 1987 11:40195
Here are the routines.  The first two perform an unsigned subtraction or
addition of a delta time value from/to an absolute value.  Useful for
figuring out "what would the time be 10 days and 4 hours from now", etc.
Had I known about the LIB$SUBx type calls, I probably would have used them.
I searched high and low through the MTH$ RTL routines and found nothing
(which was no surprise since the VAX has no integer quadword arithmetic 
instructions), so I gave up.

The last two routines are LOGICAL routines which do comparisons of absolute
times.  Use like :  IF ( DATE_LE(abs_time1, abs_time2) ) THEN
All arguments are quadword types except the result of the functions.  I use
REAL*8 to hold binary time values, I am sure that any 8 byte entity would
work (array of 8 BYTEs, array of 2 INTEGER*4, etc.).  To use, do an
EXTRACT DATE.MAR from NOTES, edit the file to get rid of the header text,
and do a MACRO DATE to produce the object.


	.TITLE	DATE_ROUTINES - Date arithmetic support routines
	.IDENT	/01.00/

	.PSECT	DATE_ROUTINES, PIC, EXE, REL, SHR, RD, NOWRT

;==============================================================================
;	S U B _ D A T E
;==============================================================================
;	General Electric Corporation
;	NORYL Products Division
;	Selkirk, N.Y.
;
;------------------------------------------------------------------------------
;	Author:	Alan M. Kozakiewicz
;	Version: 1.00
;	Date:	17-November-1986
;
;	Modification history:
;	(ECO)		(Date)		(Who)
;
;------------------------------------------------------------------------------
;	Description:
;
;		Called with CALLG instruction (AP => argument list). Performs
;	an unsigned subtraction of a delta time value from and absolute time
;	value and returns an absolute time value.  P1 = P2 - P3
;------------------------------------------------------------------------------
;	Inputs:
;------------------------------------------------------------------------------
;	Outputs:
;------------------------------------------------------------------------------
;
	.ENTRY	SUB_DATE,^M<>

;	P1 = RESULT
;	P2 = ABSOLUTE TIME
;	P3 = DELTA TIME

	MOVQ	@8(AP), @4(AP)		; Move absolute time to result
	MOVL	12(AP), R2		; R2 point to delta time
	MOVL	4(AP), R1		; R1 point to result
	MCOML	(R2), (R2)		; Change delta time to absolute
	MCOML	4(R2), 4(R2)
	SUBL	(R2), (R1)		; Subtract both halves
	SBWC	4(R2), 4(R1)

	RET

;==============================================================================
;	A D D _ D A T E
;==============================================================================
;	General Electric Corporation
;	NORYL Products Division
;	Selkirk, N.Y.
;
;------------------------------------------------------------------------------
;	Author:	Alan M. Kozakiewicz
;	Version: 1.00
;	Date:	17-November-1986
;
;	Modification history:
;	(ECO)		(Date)		(Who)
;
;------------------------------------------------------------------------------
;	Description:
;
;		Called with CALLG instruction (AP => argument list). Performs
;	an unsigned addition of a delta time value and an absolute time
;	value and returns an absolute time value.  P1 = P2 + P3
;------------------------------------------------------------------------------
;	Inputs:
;------------------------------------------------------------------------------
;	Outputs:
;------------------------------------------------------------------------------
;
	.ENTRY	ADD_DATE,^M<>

;	P1 = RESULT
;	P2 = ABSOLUTE TIME
;	P3 = DELTA TIME

	MOVQ	@8(AP), @4(AP)		; Move absolute time to result
	MOVL	12(AP), R2		; R2 point to delta time
	MOVL	4(AP), R1		; R1 point to result
	MCOML	(R2), (R2)		; Change delta time to absolute
	MCOML	4(R2), 4(R2)
	ADDL	(R2), (R1)		; Add both halves
	ADWC	4(R2), 4(R1)

	RET

;==============================================================================
;	D A T E _ L E
;==============================================================================
;	General Electric Corporation
;	NORYL Products Division
;	Selkirk, N.Y.
;
;------------------------------------------------------------------------------
;	Author:	Alan M. Kozakiewicz
;	Version: 1.00
;	Date:	18-November-1986
;
;	Modification history:
;	(ECO)		(Date)		(Who)
;
;------------------------------------------------------------------------------
;	Description:
;
;		Called with CALLG instruction (AP => argument list). Performs
;	a comparison (unsigned) of the two arguments.  Sets result (R0) to
;	TRUE if (P1 .LE. P2).
;------------------------------------------------------------------------------
;	Inputs:
;------------------------------------------------------------------------------
;	Outputs:
;------------------------------------------------------------------------------
;
	.ENTRY	DATE_LE,^M<>

	CLRL		R0			; Set to FALSE
	MOVL		4(AP), R1		; R1 => P1
	MOVL		8(AP), R2		; R2 => P2
	CMPL		4(R1), 4(R2)		; IS P1 .LE. P2 ?
	BGTRU		20$			; No way, GT
	BLSSU		10$			; Yes, LT
	CMPL		(R1), (R2)		; Check the low order if EQ
	BGTRU		20$			; GT

10$:	MOVL		#1, R0			; Set result to TRUE

20$:
	RET

;==============================================================================
;	D A T E _ G E
;==============================================================================
;	General Electric Corporation
;	NORYL Products Division
;	Selkirk, N.Y.
;
;------------------------------------------------------------------------------
;	Author:	Alan M. Kozakiewicz
;	Version: 1.00
;	Date:	18-November-1986
;
;	Modification history:
;	(ECO)		(Date)		(Who)
;
;------------------------------------------------------------------------------
;	Description:
;
;		Called with CALLG instruction (AP => argument list). Performs
;	a comparison (unsigned) of the two arguments.  Sets result (R0) to
;	TRUE if (P1 .GE. P2).
;------------------------------------------------------------------------------
;	Inputs:
;------------------------------------------------------------------------------
;	Outputs:
;------------------------------------------------------------------------------
;
	.ENTRY	DATE_GE,^M<>

	CLRL		R0			; Set to FALSE
	MOVL		4(AP), R1		; R1 => P1
	MOVL		8(AP), R2		; R2 => P2
	CMPL		4(R1), 4(R2)		; IS P1 .GE. P2 ?
	BLSSU		20$			; No way, LT
	BGTRU		10$			; Yes, GT
	CMPL		(R1), (R2)		; Check the low order if EQ
	BLSSU		20$			; LT

10$:	MOVL		#1, R0			; Set result to TRUE

20$:
	RET

	.END
535.7translate, PleaseMTBLUE::WILLIAMS_RICWed Dec 02 1987 07:3920
    
    I tried to use the previous routines (.6) to give me a one week advance
    notice of the events on my calendar data list, but I all I got was
    errors.  I don't know how to pass the "AP => argument list" with
    a "R ADD_DATE".  Unless it fits with "^M<>" in some that I haven't
    tried.
    
    Could you give me a more specific example of the syntax necessary
    to compare an entry from a date list, to (today + 1 week)'s date;
    
    I'm not much of a programer, and I'm certainly no Hacker, but I
    sure would like to get this feature installed in my auto-appointment
    reminder.
    
    Dick
    
    
    
    
     
535.8BMT::KOZAKIEWICZShoes for industrySun Dec 06 1987 23:3617
If I were a FORTRAN programmer (which I are, so what?), a code segment
might look like this:

	REAL*8	NOW		! Will hold todays date
	REAL*8	DELTA		! Will hold increment
	REAL*8	FUTURE		! Will hold result
	CHARACTER*27 STR

	CALL SYS$BINTIM('-- ::.',NOW)		!Get the date/time now
	CALL SYS$BINTIM('7 12:00:00.00',DELTA)	!7 Days and 12 hours into the
C						 future

	CALL ADD_DATE (FUTURE, NOW, DELTA)

	CALL SYS$ASCTIM (, STR, FUTURE, )	! Convert to ASCII
	TYPE *, STR				! Print out result

535.9THANKSMTBLUE::WILLIAMS_RICMon Dec 07 1987 05:144
    
    re: .8
    Thanks, I'll try it.