From aadfbe890ace93a43e1d22bb688692f5c73bb2be Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Fri, 27 Jul 2018 17:07:58 +0100 Subject: [PATCH] Make (STATUS DATE) return a four-digit year. This is a change to the API, but existing users are already inconsistent in how they handle 2-digit years -- some assume it's year % 100 (as the documentation says), some assume it's year - 1900, and some string-prepend "19" -- so most have Y2K problems that need fixing. As it's now reading the date using two UUOs, it needs to be careful to check that the year hasn't rolled over between the two, as LIBDOC; TIME does for the day. I've updated all four implementations of SDATE, but only tested the ITS version. --- doc/info/lispa.5 | 2 +- src/l/{status.265 => status.266} | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-) rename src/l/{status.265 => status.266} (99%) diff --git a/doc/info/lispa.5 b/doc/info/lispa.5 index 7dde6eb5..a02ab168 100755 --- a/doc/info/lispa.5 +++ b/doc/info/lispa.5 @@ -3599,7 +3599,7 @@ Note: the various enquiries related to time may return nil in the rare circumstance that LISP cannot determine what time it is. date (status date) returns a 3-list of fixnums indicating the current date - as (last-two-digits-of-the-year month-number day). + as (year month-number day). The year value is complete (e.g. 2001.). dow (status dow) returns an interned atomic symbol which is the name of the current day of the week. diff --git a/src/l/status.265 b/src/l/status.266 similarity index 99% rename from src/l/status.265 rename to src/l/status.266 index 140bde6f..c9d4da8d 100644 --- a/src/l/status.265 +++ b/src/l/status.266 @@ -617,15 +617,26 @@ SUBTTL STATUS TIME, DATE, UNAME, USERID, JNAME, JNUMBER, SUBSYSTEM IFN ITS,[ STIME: .RTIME TT, - JRST SDATE+1 - -SDATE: .RDATE TT, AOJE TT,FALSE MOVE D,TT SUB D,[202020202021] ;21 ADJUSTS FOR THE AOJE - JSP F,STCVT - JSP F,STCVT - JSP F,STCVT + JSP F,STCVT ;Hour + JRST SDAT2 + +SDATE: .RYEAR T, ;Get year info + JUMPE T,FALSE + .RDATE D, ;Get sixbit date + AOJE D,FALSE + .RYEAR TT, ;Has the year just rolled over? + CAME T,TT + JRST SDATE ; Happy new year! Try again + HRRZ TT,T ;4-digit year + JSP T,FXCONS + PUSH P,A + SUB D,[202020202021] ;21 adjusts for the AOJE + LSH D,12. ;Discard 2-digit year +SDAT2: JSP F,STCVT ;Month (or minute) + JSP F,STCVT ;Day (or second) MOVNI T,3 JRST LIST @@ -710,7 +721,6 @@ SDATE: MOVE R,[%CNYER] MOVE TT,[%CNDAY] GETTAB R, JRST FALSE - SUBI R,1900. JRST STIM2 STIME: MOVE R,[%CNHOR] @@ -741,7 +751,7 @@ SDATE: DATE D, ;DATE IN D = <*12.+MONTH-1>*31.+DAY-1 MOVE T,R IDIVI D,12. ;REMAINDER HERE IS MONTH-1 AOJ R, - ADDI D,64. ;QUOTIENT IN D IS YEAR-1964. + ADDI D,1964. ;QUOTIENT IN D IS YEAR-1964. PUSH FXP,D PUSH FXP,R PUSH FXP,T @@ -812,7 +822,6 @@ STIME1: PUSHJ P,CONS1FX ;CONS R, D, TT INTO A LIST OF FIXNUMS SDATE: PUSHJ P,SDATIM ;RETURNS DATE IN D AND R HLRZ TT,R ;DAY-1 HLRZ R,D ;YEAR - SUBI R,1900. ;REDUCE IT TO A YEAR MOD 100. MOVEI D,1(D) ;MONTH AOJA TT,STIME1 ;INCREMENT DAY-1 TO DAY, AND GO CONS