mirror of
https://github.com/byteworksinc/ORCALib.git
synced 2024-06-14 03:29:41 +00:00
Compute tm_yday and tm_wday directly in ~gmlocaltime.
This avoids calling mktime (future versions of which may call ~gmlocaltime), and also deals correctly with time zones.
This commit is contained in:
parent
882af9e075
commit
7e4f067c35
28
time.asm
28
time.asm
|
@ -588,6 +588,7 @@ lb2b dec month
|
||||||
lda month set the month
|
lda month set the month
|
||||||
ldy #tm_mon
|
ldy #tm_mon
|
||||||
sta [tm],y
|
sta [tm],y
|
||||||
|
ph4 <t save original t value
|
||||||
sub4 t,count find the number of seconds
|
sub4 t,count find the number of seconds
|
||||||
move4 t,t1
|
move4 t,t1
|
||||||
div4 t,#60
|
div4 t,#60
|
||||||
|
@ -614,8 +615,31 @@ lb2b dec month
|
||||||
inc A
|
inc A
|
||||||
ldy #tm_mday
|
ldy #tm_mday
|
||||||
sta [tm],y
|
sta [tm],y
|
||||||
ph4 tm set the day of week/year
|
pl4 t restore original t value
|
||||||
jsl mktime
|
stz month compute the days since the start of the
|
||||||
|
jsr factor_second32 year (in desired time zone)
|
||||||
|
sub4 t,count,count
|
||||||
|
div4 count,#60*60*24
|
||||||
|
ldy #tm_yday set the day of year
|
||||||
|
lda count
|
||||||
|
sta [tm],y
|
||||||
|
lb3 cmpl t,#7*3000*60*60*24 compute the day of week
|
||||||
|
blt lb3a
|
||||||
|
sub4 t,#7*3000*60*60*24
|
||||||
|
bra lb3
|
||||||
|
lb3a add4 t,#4*60*60*24
|
||||||
|
sec (adjust for time zone)
|
||||||
|
lda t
|
||||||
|
sbc tz_offset
|
||||||
|
sta t
|
||||||
|
lda t+2
|
||||||
|
sbc tz_offset+2
|
||||||
|
sta t+2
|
||||||
|
div4 t,#60*60*24
|
||||||
|
mod4 t,#7
|
||||||
|
lda t set the day of week
|
||||||
|
ldy #tm_wday
|
||||||
|
sta [tm],y
|
||||||
lda isdst set the DST flag
|
lda isdst set the DST flag
|
||||||
ldy #tm_isdst
|
ldy #tm_isdst
|
||||||
sta [tm],y
|
sta [tm],y
|
||||||
|
|
12
time.macros
12
time.macros
|
@ -655,3 +655,15 @@
|
||||||
sta &n1+6
|
sta &n1+6
|
||||||
~restm
|
~restm
|
||||||
mend
|
mend
|
||||||
|
macro
|
||||||
|
&l cmpl &n1,&n2
|
||||||
|
lclb &yistwo
|
||||||
|
&l ~setm
|
||||||
|
~lda.h &n1
|
||||||
|
~op.h cmp,&n2
|
||||||
|
bne ~a&SYSCNT
|
||||||
|
~lda &n1
|
||||||
|
~op cmp,&n2
|
||||||
|
~a&SYSCNT anop
|
||||||
|
~restm
|
||||||
|
mend
|
||||||
|
|
Loading…
Reference in New Issue
Block a user