From f15caf8096d900c44fc6d16697d753dd97cbdd85 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Thu, 29 Dec 2022 23:17:24 -0600 Subject: [PATCH] Make gmtime/localtime properly support times near the limits of the time_t range. They did not properly handle times in 1969 or 2105 (for the latter, they would infinite-loop). --- time.asm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/time.asm b/time.asm index 0c12ba0..2fcd8e4 100644 --- a/time.asm +++ b/time.asm @@ -510,22 +510,27 @@ lb1 plb stz second lb1 inc year jsr factor + lda count+4 + bne lb1b lda count+2 cmp t+2 bne lb1a lda count cmp t lb1a ble lb1 - dec year +lb1b dec year lb2 inc month find the month jsr factor + lda count+4 + bmi lb2 + bne lb2b lda count+2 cmp t+2 bne lb2a lda count cmp t lb2a ble lb2 - dec month +lb2b dec month jsr factor recompute the factor lda year set the year sta tm_year