🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.scheme.c
2 messages
2 total messages Started by Michael R. Blair Fri, 31 Jul 1992 20:46
real-time v decoded-time
#3
Author: Michael R. Blair
Date: Fri, 31 Jul 1992 20:46
11 lines
947 bytes
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.

ziggy
Re: real-time v decoded-time
#4
Author: 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.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads