1
0
mirror of https://github.com/PDP-10/its.git synced 2026-03-02 01:50:24 +00:00
Files
PDP-10.its/src/syseng/ctimsr.17
Björn Victor a65a038146 Support for time zones and non-US DST
Use bits in .RYEAR/.RLPDTM result to return a local time zone,
TZONE (definable in SYSTEM;CONFIG).
TZONE should be the integer timezone offset (hours West of UTC)
	Bit 4.4      => timezone known (otherwise, assume EST/EDT = 5)
	Bit 4.3      => sign bit of timezone offset
	Bits 3.5-3.1 => absolute value of timezone offset

If DSTEU is defined and != 0, calculate daylight savings time
according to European Union rules:
- starts at 2:00 (standard time) on the last Sunday in March,
- ends at 2:00 (standard time) on the last Sunday in October.
2021-06-23 17:07:11 +02:00

131 lines
2.8 KiB
Plaintext
Executable File

;; DLW 1/26/77 -*-Fundamental-*-
TITLE CHAOS NET TIME SERVER
A=1
B=2
C=3
P=17
GMTDIF==5 ; Difference between EST and GMT zones.
NETI==1
NETO==2
.INSRT SYSTEM;CHSDEF >
; The offical contact name is "TIME". The server sends an ANS of 4 bytes.
; The first word of data is the LOW order 16 bits, and the second word
; the HIGH order 16 bits of the number of seconds since Jan 1,1900, midnight GMT.
; Each 16-bit word is made up of two 8-bit bytes in pdp11 order, which is
; wrong for pdp10's. Beware.
PKTBUF: BLOCK %CPMXW ; Packet buffer.
DEBUG: 0 ; -1 => debugging.
PDL: -10,,.
BLOCK 10
GO: MOVE P,PDL
MOVE A,[JSR TSINT] ; Must handle IOC errors
MOVEM A,42
SKIPN DEBUG
.SUSET [.SMASK,,[%PIIOC]]
.CALL [ SETZ
SIXBIT /CHAOSO/
MOVEI NETI
MOVEI NETO
SETZI 5 ] ;WINDOW SIZE = 5 (ha ha)
JSR LOGOUT
;; Construct and send the LSN packet.
MOVEI A,%COLSN
DPB A,[$CPKOP+PKTBUF] ; OPCODE = LSN
MOVE A,[.BYTE 8 ? "T ? "I ? "M ? "E]
MOVEM A,PKTBUF+%CPKDT
MOVEI A,4
DPB A,[$CPKNB+PKTBUF]
.CALL [SETZ ? 'PKTIOT ? MOVEI NETO ? SETZI PKTBUF]
JSR LOGOUT
;; Wait for the RFC to come.
MOVEI A,%CSLSN ; Listening state.
MOVEI B,30.*30. ; 30. second timeout.
SKIPE DEBUG
MOVSI B,177777 ; or infinite if in debug mode.
.CALL [ SETZ
SIXBIT /NETBLK/
MOVEI NETO
A
B
SETZM C]
JSR LOGOUT
CAIE C,%CSRFC ; RFC received state
JSR LOGOUT
;; Construct and send the ANS.
MOVEI A,%COANS
DPB A,[$CPKOP+PKTBUF]
MOVEI A,4
DPB A,[$CPKNB+PKTBUF]
PUSHJ P,GETTIM ; Get time in A.
MOVE C,[440800,,B]
IDPB A,C
LSH A,-10
IDPB A,C
LSH A,-10
IDPB A,C
LSH A,-10
IDPB A,C
MOVEM B,%CPKDT+PKTBUF ; Data.
.CALL [ SETZ ? 'PKTIOT ? MOVEI NETO ? SETZI PKTBUF]
JSR LOGOUT
;; Wait for the ANS to get sent, and die.
.CALL [ SETZ
SIXBIT /FINISH/
SETZI NETO]
JSR LOGOUT
JSR LOGOUT
LOGOUT: 0
SKIPL DEBUG
.LOGOUT
.VALUE
GETTIM: .RLPDTM A, ; Get in A, # secs since beg of year.
CAME A,[-1]
CAMN B,[-1]
JSR LOGOUT ; If either is -1, time not known.
push p,b ;[BV] save ryear result
CAIGE B, ; If 4.9 on,
SUBI A,24.*3600. ; subtract 1 day - .RLPDTM misfeature!
TLNE B,100000 ; Bit 4.7 = Daylight Savings time?
SUBI A,3600. ; If on, subtract one hour to get Standard.
MOVEI B,-1900.(B) ; Get year, relative to 1900.
MOVEI C,-1(B) ; Adjust and
LSH C,-2 ; Get # leap years since 1900 not including this year.
IMULI B,365. ; Find # days in years thus far
ADDI B,(C) ; Plus # LY's, to get total days in years past.
IMULI B,86400. ; Now get # seconds in all them days.
ADD A,B ; and produce total seconds since 1/1/00 !
;;[BV] TZ hack
pop p,c
tlnn c,10000 ; TZ known?
jrst getti0 ; no
ldb b,[230400,,c] ; Get absolute TZ
tlne c,4000 ; Negative?
movns b
skipa
getti0: movei b,GMTDIF ; Default TZ=5
imuli b,3600.
add a,b
POPJ P,
TSINT: 0 ? 0
JSR LOGOUT ; IOC error
END GO