home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / jsage / znode3 / uploads / zslsrc36.lbr / SDATS1.ZZ0 / SDATS1.Z80
Encoding:
Text File  |  1991-10-08  |  1.6 KB  |  87 lines

  1. ; Library:    ZSLIB
  2. ; Version:    3.4
  3. ; Module:    SDATS1
  4. ; Version:    1.0
  5. ; Author:    Gene Pizzetta
  6. ; Date:        October 8, 1991
  7. ;
  8. ; SDATS1 -- Prints long form of date in American or European format, e.g.,
  9. ; "March 2, 1988" or "2 March 1988", with switchable output.
  10. ;
  11. ; Entry:  HL = address of date as BCD yy mm dd
  12. ;      A = date format flag (0=American, FFh=European)
  13. ; Exit:   None
  14. ; Uses:   None
  15. ;
  16.     PUBLIC    SDATS1
  17. ;
  18.     EXTRN    DSTRMO,SAFHC,ZOUT    ; ZSLIB
  19.     EXTRN    SA2HC,SPSTR        ; SYSLIB
  20. ;
  21. SDATS1:    ld    (DatFmt),a    ; save format byte
  22.     push    hl
  23.     push    de
  24.     push    bc
  25.     push    af
  26.     ld    c,(hl)        ; save year
  27.     inc    hl
  28.     ld    b,(hl)        ; save month
  29.     inc    hl
  30.     ld    a,(hl)
  31.     push    af        ; save day
  32.     ld    a,(DatFmt)    ; format?
  33.     or    a
  34.     jr    z,DoMnth    ; (American)
  35. ; Print day if European format
  36.     pop    af        ; get day
  37.     call    SAFHC
  38.     call    Space
  39. ; Print month
  40. DoMnth:    xor    a        ; clear carry for DAA
  41.     ld    hl,DSTRMO    ; point to months table
  42.     ld    a,b        ; get month
  43. NxtMth:    ld    e,(hl)
  44.     inc    hl
  45.     ld    d,(hl)
  46.     inc    hl
  47.     dec    a
  48.     daa            ; decimal adjust
  49.     jr    nz,NxtMth
  50.     ex    de,hl        ; HL --> month
  51.     call    SPSTR        ; print month
  52.     call    Space
  53.     ld    a,(DatFmt)    ; format?
  54.     or    a
  55.     jr    nz,DoYear    ; (European)
  56. ; Print day if American format
  57.     pop    af        ; get day
  58.     call    SAFHC
  59.     ld    a,','        ; print comma
  60.     call    ZOUT
  61.     call    Space
  62. ; Print year
  63. DoYear:    ld    a,c        ; get year
  64.     cp    78h
  65.     ld    a,19h
  66.     jr    nc,Cent20    ; 20th century
  67.     ld    a,20h
  68. Cent20:    call    SAFHC        ; century
  69.     ld    a,c
  70.     call    SA2HC        ; year
  71.     pop    af
  72.     pop    bc
  73.     pop    de
  74.     pop    hl
  75.     ret
  76. ;
  77. Space:    ld    a,' '
  78.     jp    ZOUT
  79. ;
  80. ; Data
  81. ;
  82.     DSEG
  83. ;
  84. DatFmt:    ds    1
  85. ;
  86.     end
  87.