From e2de990f4d5c608cc191ad9d94a2df27571d22a5 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Wed, 28 Dec 2022 19:55:48 -0600 Subject: [PATCH] strftime: use Time Tool Set to get time zone offset. This is used for the %z conversion specifier (giving the time zone offset in +-HHMM format). The %Z conversion specifier (giving the locale's time zone name or abbreviation) also prints the same thing for now. As with gmtime, this will only use the Time Tool Set if it has already been started. Otherwise, these conversions simply produce no output. --- time.asm | 54 ++++++++++++++++++++++++++++++++++++++++++++++++----- time.macros | 5 +++++ 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/time.asm b/time.asm index f323c77..9cbc246 100644 --- a/time.asm +++ b/time.asm @@ -1098,12 +1098,56 @@ Y_skip inx rts ;%z - offset from UTC, if available -;we print nothing, because time zone info is not available -fmt_z rts - ;%Z - time zone name or abbreviation, if available -;we print nothing, because time zone info is not available -fmt_Z rts +;we print the numeric offset for both, or nothing if time zone is not available +fmt_z anop +fmt_Z pha check if time tool is active + _tiStatus + pla + bcs z_ret + beq z_ret + pea 0 push pointer to string buffer + tdc +; clc + adc #numstr + pha + pha make space for TZ preferences record + pha + pea 1 get one record element only (TZ offset) + tsc get time zone preference + inc a + pea 0 + pha + _tiGetTimePrefs + pla + bcc z_dst +z_bail pla bail out in case of error + pla + pla + pla +z_ret rts +z_dst ldy #tm_isdst adjust for DST (+1 hour) if needed + lda [timeptr],y + bmi z_bail bail out if DST is unknown + beq z_fmtstr +; clc + pla + adc #60*60 + tay + pla + adc #0 + pha + phy +z_fmtstr pea 0 no DST mangling + _tiOffset2TimeZoneString get TZ offset string + bcs z_ret + ldx #1 +z_loop lda numstr,x print the digits + jsr writech + inx + cpx #5+1 + blt z_loop + rts fmt_invalid rts diff --git a/time.macros b/time.macros index c9db57c..e291e83 100644 --- a/time.macros +++ b/time.macros @@ -631,3 +631,8 @@ &lab ldx #$0938 jsl $E10000 MEND + MACRO +&lab _tiOffset2TimeZoneString +&lab ldx #$1138 + jsl $E10000 + MEND