🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.scheme.c
Article #4

Re: real-time v decoded-time

#4
From: Guillermo J. Rozas
Date: Sat, 01 Aug 1992 04:52
43 lines
2357 bytes
In article <9207312050.AA06212@bloom-beacon.MIT.EDU> ziggy@swatch.ai.mit.EDU (Michael R. Blair) writes:

*   Is there some variable or parameter in MIT Scheme that will show me the
*   decoded time at which the Scheme was started?

*   Why do I ask? Well, (real-time-clock) gives time since Scheme started
*   whereas (get-decoded-time) returns a structure of YMDhms of the current
*   local time zone time. What I want to do is define DECODED-TIME->REAL-TIME
*   and REAL-TIME->DECODED-TIME. Since the decoded time is grounded on midnight
*   Dec 31 1900, whereas real-time is grounded on whenever Scheme was started,
*   I need a way of regrounding one in terms of the other.

You don't need that parameter defined.  You can define the procedures anyway:

(define (with-synchronized-times receiver)
  (apply receiver
	 ;; Prevent GC from splitting times
	 (with-absolutely-no-interrupts
	   (lambda ()
	     (list (real-time-clock)
		   (get-decoded-time))))))

(define real-time->decoded-time
  (with-synchronized-times
    (lambda (real-time-now decoded-time-now)
      (lambda (real-time)
	(decoded-time/+ decoded-time-now
			(real-time/- real-time real-time-now))))))

(define decoded-time->real-time
  (with-synchronized-times
    (lambda (real-time-now decoded-time-now)
      (lambda (decoded-time)
      (let ((decoded-time-difference))
	(real-time/+ real-time-now
		     (decoded-time/- decoded-time decoded-time-now)))))))
			     
where you would need to write REAL-TIME/- REAL-TIME/+ DECODED-TIME/-
and DECODED-TIME/+ in the obvious but painful way.

Of course, if you want to dump a band and restart it later, you'll
have to resynhronize the times.  To do that, you'll have to add an
event-receiver for the after-restart event.
Technical Details
Message-ID: <JINX.92Aug1005229@chamarti.ai.mit.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!yale!mintaka.lcs.mit.edu!ai-lab!zurich.ai.mit.edu!jinx
References: <9207312050.AA06212@bloom-beacon.MIT.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!yale!mintaka.lcs.mit.edu!ai-lab!zurich.ai.mit.edu!jinx
From: jinx@zurich.ai.mit.edu (Guillermo J. Rozas)
Newsgroups: comp.lang.scheme.c
Subject: Re: real-time v decoded-time
Message-ID: <JINX.92Aug1005229@chamarti.ai.mit.edu>
Date: 1 Aug 92 04:52:29 GMT
References: <9207312050.AA06212@bloom-beacon.MIT.EDU>
Sender: news@ai.mit.edu
Reply-To: jinx@zurich.ai.mit.edu
Organization: M.I.T. Artificial Intelligence Lab.
Lines: 43
In-reply-to: ziggy@swatch.ai.mit.EDU's message of 31 Jul 92 20:46:05 GMT