Fix asctime() to properly print years 1000 through 9999.

Also, use a leading space rather than a leading 0 in days 1 through 9.

This fixes the libca11.c test case.
This commit is contained in:
Stephen Heumann 2018-03-09 13:10:53 -06:00
parent 73f04eaab4
commit a77e44d7b5
1 changed files with 17 additions and 10 deletions

View File

@ -137,7 +137,10 @@ tm_wday equ 12
ldy #tm_mday convert the day to a string
lda [timeptr],Y
jsr mkstr
sta str+8
bit #$00CF check for leading '0'
bne lb1
and #$FFEF convert leading '0' to ' '
lb1 sta str+8
ldy #tm_hour convert the hour to a string
lda [timeptr],Y
jsr mkstr
@ -151,17 +154,21 @@ tm_wday equ 12
jsr mkstr
sta str+17
ldy #tm_year convert the year to a string
lda #'91'
sta str+20
lda [timeptr],Y
cmp #100
blt lb1
ldx #'02'
stx str+20
sec
sbc #100
lb1 jsr mkstr
ldy #19
sec
yr1 iny
sbc #100
bpl yr1
clc
yr2 dey
adc #100
bmi yr2
jsr mkstr
sta str+22
tya
jsr mkstr
sta str+20
lla timeptr,str
plb