; PROGRAM: JULTEST.Z80 ; AUTHOR: Howard Goldstein ; DATE: 4/16/88 ; This program was written to test/demonstrate the routines in ; JULIAN.REL. If invoked with no tokens on the command line, it will ; prompt for Gregorian date and convert it to Julian. If invoked ; with a "J" on the command line, it will prompt for Julian date and ; convert to Gregorian. ; This program is meant for demonstration purposes and is somewhat ; skeletal in nature. It does not validate Gregorian dates as well ; as it probably should. If anyone wants to improve it and make it ; into a real utility, be my guest! extrn bin2jul,jul2bin ; julian extrn pafdc,phlfdc ; syslib routines extrn eval10,eprint,crlf,cout,bline cr equ 13 lf equ 10 bdos equ 5 tbuff equ 80h fcb equ 5ch start: ld (stack),sp ; save system stack ld sp,stack ; set up local stack ld a,(fcb+1) ; check command line token cp 'J' jr nz,grgprmpt ; if not 'J' prompt for gregorian date ; prompt for julian date julprmpt: ld de,julmsg ld c,9 ; print string function call bdos call input ; get response call eval10 ex de,hl ; get converted number in hl jr prtjul ; go print julian date and convert ; prompt for gregorian date and validate (sort of) grgprmpt: ld de,grgmsg ld c,9 ; bdsos print string function call bdos call input ; get user's response cp 8 ; must be exactly 8 chars jr nz,baddate call eval10 ; convert month to binary or a ; month can't be 0 jr z,baddate cp 13 ; can't be >12 jr nc,baddate ld (month),a ; store month inc hl ; skip over slash and point to day call eval10 ; convert or a ; day can't be 0 jr z,baddate cp 32 ; or >31 jr nc,baddate ld (day),a ; store day inc hl ; point to year call eval10 ld (year),a ; store year ; convert to julian cnv2jul: ld hl,year ; pt at date call bin2jul ; get jul date in hl prtjul: call eprint defz cr,lf,'Julian date: ' call phlfdc call jul2bin ; convert to gregorian call eprint defz ', Gregorian: ' ld a,b ; month call pafdc ld a,'/' call cout ld a,l ; day call pafdc ld a,'/' call cout ld l,c ; get two-digit year ld de,1900 ; de = base century ld h,0 add hl,de ;add century call phlfdc ; and print call crlf exit: ld sp,(stack) ; restore system stack ret ; and return to system baddate: ld a,7 ; beep at the dummy call cout jp grgprmpt ; and make him get it right ; This routine sets up a BDOS function 10 style buffer and then ; uses the SYSLIB BLINE routine to get user's input. BLINE returns ; with string length in A and address of beginning of string in HL. input: ld hl,tbuff ; use tbuff as input buffer ld (hl),20 ; set max string length jp bline julmsg: defz cr,lf,'Enter Julian date (days since 12/31/1987): $' grgmsg: defz cr,lf,'Enter Gregorian date (mm/dd/yy): $' dseg year: defs 1 month: defs 1 day defs 1 ds 48 ; room for stack stack: ds 2 end