CompuServe Thread

Setting System Time?

6 messages in this thread
#42557From: Martin KaySep 10, 1994 4:22 AM
Help! Does anyone have, or know of, some code fragments to set the system Time-of-Day clock (as opposed to the Battery-Backed clock)? I have a need to synchronize the Amiga system time to an external clock source. I can do it by re-setting the BattClock chip (via Resources & Utility.library) and then executing "SetClock Load", but that's not as neat as I'd like it. I can't find anything in all my Amiga docs about setting the system time, nor in the AmigaTech library here on CIS. What I need is a routine (in C or Asm) to take a time value (which I can supply in any suitable form) and do whatever "Date" and "SetClock" do in order to set the System Time. All info/advice appreciated Martin Kay
#42586From: Mal LansellSep 13, 1994 9:01 AM
Martin, The following is from the Amiga developer update, and outlines a battery-backed clock resource. It is available from V36 onwards. I haven't tried setting the clock myself, so if there are any other files you think you need but don't have, e-mail me and I'll see what I can do. ——————————————————————————- ——————————– TABLE OF CONTENTS battclock.resource/ReadBattClock battclock.resource/ResetBattClock battclock.resource/WriteBattClock ——————————————————————————- ——————————— NAME ReadBattClock — Read time from clock chip. (V36) SYNOPSIS AmigaTime = ReadBattClock( ) ULONG ReadBattClock( void ); D0 FUNCTION This routine reads the time from the clock chip and returns it as the number of seconds from 01-jan-1978. INPUTS None RESULTS AmigaTime – The number of seconds from 01-Jan-1978 that the clock chip thinks it is. NOTES If the clock chip returns an invalid date, the clock chip is reset and 0 is returned. ——————————————————————————- ———————————– NAME ResetBattClock — Reset the clock chip. (V36) SYNOPSIS ResetBattClock( ) void ResetBattClock( void ); FUNCTION This routine does whatever is neeeded to put the clock chip into a working and usable state and also sets the date on the clock chip to 01-Jan-1978. ——————————————————————————- ———————————– NAME WriteBattClock — Set the time on the clock chip. (V36) SYNOPSIS WriteBattClock( AmigaTime ) D0 void WriteBattClock( ULONG ); FUNCTION This routine writes the time given in AmigaTime to the clock chip. INPUTS AmigaTime The number of seconds from 01-Jan-1978 to the time that should be written to the clock chip. ——————————————————————————- ———————————– I hope this is enough. I would suggest doing a ResetBattClock first, to make sure everything is set up right, followed by WriteBattClock. Mal
#42589From: Jim MaddoxSep 13, 1994 11:21 AM
I think what Martin really wanted to know was how to set the time-of-day clock, if you can do that — I'm sure most users wouldn't want their programs playing around freely with the battery-backed one if it could be avoided. – Jim, on AutoPilot!
#42604From: Mal LansellSep 14, 1994 10:37 AM
Sorry – his reference to reseting the battery back clock first led me astray! Mal
#42590From: Werner KazmierzakSep 13, 1994 3:06 PM
Martin, to set the system time, you open the timer.device and issue an I/O-request with the Command TR_SETSYSTIME. Just have a look into the RKM "Devices" pg. #285 ff TIMER DEVICE section. – wkc – … via AP from Hamburg, Germany
#42593From: Martin KaySep 13, 1994 7:37 PM
Spot on! The Timer Device TR_SETSYSTIME command does exactly what I want (I've tried it and it works perfectly). The main problem was trying to find it amongst my hundreds of files and pages of Amiga documentation. Doing a search on the words Time, Clock, System, etc I discovered numerous structure references and function calls but, as ever, not that one! I use the Timer device quite often but I've never noticed that command. Funny how what you are loking for is so often under your nose 8^) ! Many thanks, and I hope to repay the favour one day. Martin Kay