mktime: force struct tm components to their normal ranges.

This is done by calling ~gmlocaltime after computing the time_t value in mktime.
This commit is contained in:
Stephen Heumann 2022-12-31 21:45:49 -06:00
parent 7e4f067c35
commit 44c3078ab3
1 changed files with 20 additions and 28 deletions

View File

@ -19,7 +19,18 @@
* *
**************************************************************** ****************************************************************
* *
Time start dummy segment Time private dummy segment
; struct tm fields
tm_sec gequ 0 seconds 0..59
tm_min gequ tm_sec+2 minutes 0..59
tm_hour gequ tm_min+2 hours 0..23
tm_mday gequ tm_hour+2 day 1..31
tm_mon gequ tm_mday+2 month 0..11
tm_year gequ tm_mon+2 year 69..205 (1900=0)
tm_wday gequ tm_year+2 day of week 0..6 (Sun = 0)
tm_yday gequ tm_wday+2 day of year 0..365
tm_isdst gequ tm_yday+2 daylight savings? 1 = yes, 0 = no
end end
**************************************************************** ****************************************************************
@ -531,16 +542,6 @@ lb1 plb
* *
~gmlocaltime private ~gmlocaltime private
using TimeCommon using TimeCommon
tm_sec equ 0 seconds 0..59
tm_min equ tm_sec+2 minutes 0..59
tm_hour equ tm_min+2 hours 0..23
tm_mday equ tm_hour+2 day 1..31
tm_mon equ tm_mday+2 month 0..11
tm_year equ tm_mon+2 year 69..205 (1900=0)
tm_wday equ tm_year+2 day of week 0..6 (Sun = 0)
tm_yday equ tm_wday+2 day of year 0..365
tm_isdst equ tm_yday+2 daylight savings? 1 = yes, 0 = no
csubroutine (4:tz_offset,4:t,2:isdst,4:tm),0 csubroutine (4:tz_offset,4:t,2:isdst,4:tm),0
phb phb
@ -672,7 +673,7 @@ temp2 equ 5 temp variable
phk phk
plb plb
ldy #10 set time parameters ldy #tm_year set time parameters
lda [tmptr],Y lda [tmptr],Y
sta year sta year
dey dey
@ -702,22 +703,13 @@ temp2 equ 5 temp variable
sta temp+2 sta temp+2
brl lb1 brl lb1
lb0 move4 count,temp save the value for later return lb0 move4 count,temp save the value for later return
lda #1 compute the days since the start of the ph4 <tmptr recompute struct tm values
sta day year ldy #tm_isdst
stz month lda [tmptr],y
jsr factor pha
sub4 temp,count,count ph4 <temp
div4 count,#60*60*24 ph4 #0
ldy #14 set the days jsl ~gmlocaltime
lda count
sta [tmptr],Y
div4 temp,#60*60*24,temp2 compute the day of week
add4 temp2,#4
mod4 temp2,#7
lda temp2 set the day of week
ldy #12
sta [tmptr],Y
lb1 plb lb1 plb
creturn 4:temp creturn 4:temp
end end