Subject: Re: A3000 system clock
To: None <amiga@NetBSD.ORG>
From: D. Champion <>
List: amiga
Date: 12/10/1995 02:46:12
Ty Sarna wrote:
>In article <>,
>Stephen Champion  <> wrote:
>> 	Any case, AmigaDos doesn't neccessarily expect anything from the
>> battery clock.  As long as calls to the system clock get the correct time,
>Certainly it does. By default, it expects it to contain the correct
>local time.

I don't intend to get into any fights here, but I think what Steve was
saying -- based on the rest of his content -- is that there's a battery-
based clock and a "system clock" maintained by the OS, and that they can
be out of sync with one another.  The OS only expects its own clock to
contain correct localtime; the battery clock can be set to anything you
wish without impacting the system at all, unless you have weird software
which insists on using the battery resource.

All said, I don't know whether this is true; I only know it seems to cause
me no trouble to pretend it is.

>> 	If you don't feel like whipping one up yourself, there's a copy of my
>> brother's system clock setting script in the tools/ dir of your favourite
>> uni-r mirror.  ftp://<mirror>/pub/NetBSD0Amiga/tools/warpdate.rexx.  Not 
>> perfect, but it does the job.

I posted this program to this list way back, but had no idea anyone
actually used it.  If you do... might as well use the new version at
the end of this article.  If you don't read rexx, the main advantages
of this revision are: (1) you can control time offset on command line
-- e.g., 'rx warpdate.rexx -360'; and (2) the program now reloads system
time from the battery clock at the start.  Previously, running the
script multiple times would cause you to lose or gain days or weeks

I've also added comments.  As rexx code, it probably sucks; I'm not a
rexx programmer.  Well, not until I start with the 5990.

>Fine if I you always boot from partitions on which you've modified your
>user-startup. This can't be guaranteed.

Defensive, aren't we?

>Again, all I want is the OPTION to have localtime RTC. If you want to do
>it your way, fine. The solution is simple, tiny, and completely
>optional. It doesn't even require changing a kernel option and
>recompiling. Most of the smarts lives in userspace. So why not?

Sounds good to me, although I've missed any implementational details
you've given as I usually skip over this list.  (Just caught me at a
time when I don't have procmail installed....)  Please show, if you
haven't, just because I'm curious.  If you have described it already,
I'll find it.


/* warpdate.rexx					*/
/* adjust current time so battclock can keep GMT	*/
/*							*/
/* History:						*/
/*	1.0	dgc	sometime in 1994		*/
/*		base release				*/
/*	1.1	dgc	95.09.05			*/
/*		- use zone offset if passed on cmdline	*/
/*		- pad seconds and minutes with '0' if	*/
/*		  < 10, just to be prettier		*/
/*		- load current battmemclock before	*/
/*		  updating				*/
/*							*/
/* Right-to-copy 1944 D. Champion.  No rights reserved.	*/
/* number of minutes from GMT
 * change this twice yearly if you still cope with Daylight Savings
 * As of v1.1, this is only a default -- pass GMT offset on
 * command line to override
defoff = -300
/* read current clock from battmemclock */
address command 'setclock load'
/* get arguments */
parse arg off
/* use default if arg. is unset */
if off == ''
then do
	off = defoff
/* do not change day by default */
changeday = ''
/* find minutes after midnight */
mins = time('m')
/* adjust minutes */
mins = mins + off
/* if we go back a day, adjust minutes and changeday flag */
if mins < 0
then do
	mins = 1440 + mins
	changeday = 'yesterday'
/* if we go ahead a day, adjust minutes and changeday flag */
if mins > 1439
then do
	mins = 1440 - mins
	changeday = 'tomorrow'
/* extract new hour from minutes; set minutes to minutes since hour */
hour = trunc(mins / 60)
mins = mins - (hour * 60)
/* update seconds */
tmp = time('m')
secs = time('s')
secs = secs - (tmp * 60)
/* fill out minutes and seconds with a zero, if necessary */
if length(mins) == 1
then do
	mins = '0'mins
if length(secs) == 1
then do
	secs = '0'secs
/* create an amigados 'date' command */
datestr = 'date 'changeday' 'hour':'mins':'secs
/* and change the clock */
address command datestr
/* notify of change */
if changeday == ''
then do
	changeday = 'today'
say 'Setting clock to 'hour':'mins':'secs' ('changeday')'