;;; -*- Mode: Common-Lisp; Package: TIME; Base: 8.; Patch-File: T -*-

;;; Reason: Fixed initialize-timebase to bind *timezone* to site-option :timezone.

;;;                           RESTRICTED RIGHTS LEGEND
;;;
;;; Use, duplication, or disclosure by the Government is subject to
;;; restrictions as set forth in subdivision (c)(1)(ii) of the Rights in
;;; Technical Data and Computer Software clause at 52.227-7013.
;;;
;;;   TEXAS INSTRUMENTS INCORPORATED      
;;;   P.O. BOX 2909, M/S 2151             
;;;   AUSTIN, TEXAS 78769                 
;;;
;;; Copyright (C) 1989 Texas Instruments Incorporated.
;;; All rights reserved.

;;; Patch file for SYSTEM version 6.14
;;; Written 07/25/89 06:58:30 by BERGER,
;;; while running on ARIES from band LOD1
;;; With SYSTEM 6.13, VIRTUAL-MEMORY 6.1, EH 6.4, MAKE-SYSTEM 6.0, MICRONET 6.0, LOCAL-FILE 6.0,
;;;  BASIC-PATHNAME 6.1, NETWORK-SUPPORT-COLD 6.0, BASIC-NAMESPACE 6.1, NETWORK-NAMESPACE 6.0,
;;;  DISK-IO 6.1, DISK-LABEL 6.0, BASIC-FILE 6.2, MAC-PATHNAME 6.0, NETWORK-PATHNAME 6.0,
;;;  COMPILER 6.10, TV 6.15, DATALINK 6.0, CHAOSNET 6.0, GC 6.3, MEMORY-AUX 6.0, NVRAM 6.1,
;;;  SYSLOG 6.1, STREAMER-TAPE 6.4, UCL 6.0, INPUT-EDITOR 6.0, METER 6.1, ZWEI 6.5,
;;;  DEBUG-TOOLS 6.3, NETWORK-SUPPORT 6.0, NETWORK-SERVICE 6.1, DATALINK-DISPLAYS 6.0,
;;;  FONT-EDITOR 6.1, SERIAL 6.0, PRINTER 6.3, MAC-PRINTER-TYPES 6.1, PRINTER-TYPES 6.1,
;;;  IMAGEN 6.0, SUGGESTIONS 6.0, MAIL-DAEMON 6.2, MAIL-READER 6.2, TELNET 6.0, VT100 6.0,
;;;  NAMESPACE-EDITOR 6.0, PROFILE 6.1, VISIDOC 6.2, TI-CLOS 6.19, CLEH 6.5, IP 3.47,
;;;  Experimental CLX 6.2, CLUE 6.10, X11M 6.13, Experimental BUG 11.10,  microcode 429,
;;;  Band Name: 6.0 7/19 +clock


#!C
; From file MICRO-TIME.LISP#> KERNEL; SYS:
#10R TIME#:
(COMPILER-LET ((*PACKAGE* (FIND-PACKAGE "TIME"))
                          (SI:*LISP-MODE* :COMMON-LISP)
                          (*READTABLE* SYS:COMMON-LISP-READTABLE)
                          (SI:*READER-SYMBOL-SUBSTITUTIONS* SYS::*COMMON-LISP-SYMBOL-SUBSTITUTIONS*))
  (COMPILER#:PATCH-SOURCE-FILE "SYS: KERNEL; MICRO-TIME.#"



(DEFUN INITIALIZE-TIMEBASE (&OPTIONAL UT source)
  "Set the clock.  UT, if specified, is the universal time.  
SOURCE describes where to get the time.  NIL means try all sources.  
Other possible values of SOURCE include :NET (the network), :LOCAL (the
local clock), and :USER (ask the user)."
  (let ((Time:*timezone* (or (get-site-option :timezone) time:*timezone*)))  ; DAB 07-24-89 Otherwise time may be off 1 HR.
	(WHEN (NULL ut)
	  (SETQ ut
		(SELECT source
		  (:net (get-time-from-network))
		  (:local (get-time-from-rtc))
		  (:user (get-time-from-user))
		  (:otherwise
		   (OR (get-time-from-network)
		       (get-time-from-rtc)
		       (progn (setq source :user) (get-time-from-user)))))) )
	(WHEN ut
	  (WITHOUT-INTERRUPTS
	    (IF (NOT (NULL *UT-AT-BOOT-TIME*))
		;;if we are randomly changing the time while up, mung uptime
		(SETQ *UT-AT-BOOT-TIME*
		      (+ *UT-AT-BOOT-TIME* (- UT (GET-UNIVERSAL-TIME))))
		;;no real surprise: changing at boot time
		(SETQ *UT-AT-BOOT-TIME* UT))
	    (SETF (VALUES *LAST-TIME-UPDATE-TIME* *PREVIOUS-TOP-9-TIME-BITS*)
		  (obsolete-FIXNUM-MICROSECOND-TIME))
	    (MULTIPLE-VALUE-SETQ
	      (*LAST-TIME-SECONDS* *LAST-TIME-MINUTES* *LAST-TIME-HOURS*
	       *LAST-TIME-DAY* *LAST-TIME-MONTH* *LAST-TIME-YEAR*
	       *LAST-TIME-DAY-OF-THE-WEEK* *LAST-TIME-DAYLIGHT-SAVINGS-P*)
	      (DECODE-UNIVERSAL-TIME UT))
	    ;; Don't touch the MAC clock if on microExplorer.  ab 11/1/88.
	    (WHEN (AND (SI:RESOURCE-PRESENT-P :RTC)	
		       (or (CHAPARRAL-INITIAL-DATE-VALID-P)
			   (equalp source :user)))             ;; clm 3/1/89
	      (CHAPARRAL-SET-UNIVERSAL-TIME UT))
	    (LEAP-YEAR-SETUP)
	    ;; Make sure that the leap year times are OK.  See
	    ;; leap-year-setup for more details.
	    
      
      T))))

))