Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!ames!ucbcad!ucbvax!decvax!decwrl!sun!imagen!atari!apratt From: apratt@atari.UUcp (Allan Pratt) Newsgroups: comp.sys.atari.st Subject: Re: help - a little of your time, if not the ST's Message-ID: <488@atari.UUcp> Date: Tue, 16-Dec-86 14:47:19 EST Article-I.D.: atari.488 Posted: Tue Dec 16 14:47:19 1986 Date-Received: Wed, 17-Dec-86 23:23:30 EST References: <723@imagen.UUCP> Organization: Atari Corp., Sunnyvale CA Lines: 195 Keywords: Clock, gettime, settime The problem here is that you are changing the IKBD time/date, not the GEMDOS time/date. These are two different things. The IKBD time survives system resets, while the GEMDOS time does not. The time you see in the Control Panel (and on file stamps) is the GEMDOS time. Included below is a program which lives very happily in my AUTO folder. It checks the IKBD time, and, if it's valid, sets the GEMDOS time to that value. If the IKBD time is invalid (like on power-up) or if you specify any options on the command line, the program prompts for a new time and sets BOTH the GEMDOS and IKBD time to that. The key calls are Gettime/Settime (for the IKBD) and Tgetdate/Tsetdate and Tgettime/Tsettime (for GEMDOS). Note that the old control panel sets the GEMDOS time to zero (that is, 11/85) when it starts up (AFTER the AUTO folder executes), clobbering anything this program has done. If you have that version of the control panel, you should get the new version from the Atari bulletin board. settime.c and settime.prg (uuencoded) follow. Note that it's written for Alcyon C, and you DON'T link with GEMSTART (but you do link with osbind). Also note that it's not especially good code, but it does the job, and even has some error checking. Read the first part of the source for documentation. /************************* cut here for settime.c ************************/ /* * Settime: get the time from the Ikbd, or from the user, if that's wrong. * * usage: settime [f] * * The Intelligent Keyboard's time and date are checked for validity. * If they are valid, GEM's time and date are set accordingly. If not, * or if you provide the FORCE argument on the command line, you will * be prompted for the time and date, and BOTH GEM's and the IKBD's time * will be set to what you typed. * * If you put this program in the AUTO folder of your boot device, you * only have to set the time on power-up, not after every reset. * * The new version of the control panel will not clobber this time setting. * * Written by Allan Pratt for Atari Corp. Copyright (C) 1986 by Atari Corp. * This program may be freely copied and distributed at no charge. * * NOTE: THIS PROGRAM DOES NOT USE GEMLIB AT ALL. This makes it small & quick. * * LINK: link68 [u] settime.68k=settime,osbind * relmod settime */ #include#define fixup(s) (s[s[1]+2] = '\0') /* null-terminate a GEMDOS string */ main(basepage) register char *basepage; { register unsigned long datime; register int date, time, temp; char buffer[10]; char *s; /* set s to command line and null-terminate the string */ s = basepage + 0x81; s[basepage[0x80]] = '\0'; while (*s == ' ') s++; if (*s == '\0') { /* no force argument: see if IKBD time is valid */ datime = Gettime(); /* get ikbd date & time */ date = datime >> 16; time = datime & 0xffff; /* if the month and day are nonzero, and if GEMDOS doesn't barf on either, */ /* just exit: you're done! */ if (((date & 0x1f) != 0) && (((date >> 5) & 0x0f) != 0)) if (!Tsetdate(date) && !Tsettime(time)) Pterm(0); } /* either there was an argument (force) or ikbd's date/time was bad */ /* in any case, getting here means we want to prompt the user */ buffer[0] = 7; /* set up buffer for Cconrs call */ do { Cconws("Enter the time (hhmm[ss]): "); Cconrs(buffer); fixup(buffer); } while (dotime(buffer+2)); do { Cconws("\r\nEnter the date (mmddyy): "); Cconrs(buffer); fixup(buffer); } while (dodate(buffer+2)); datime = ((long)Tgetdate() << 16) + Tgettime(); /* get GEM's time */ Settime(datime); /* update the ikbd's time */ Cconws("\r\n"); /* be nice - end with newline */ Pterm(0); } dotime(s) register char *s; { register int len; register int hour, minute, second; len = strlen(s); if (len < 4 || len == 5 || len > 6) goto badtime; /* bad string */ hour = (s[0]-'0') * 10 + (s[1]-'0'); minute = (s[2]-'0') * 10 + (s[3]-'0'); if (len == 6) second = (s[4]-'0') * 10 + (s[5]-'0'); else second = 0; if (hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || second > 59) goto badtime; if (!Tsettime((hour << 11) + (minute << 5) + (second >> 1))) return 0; badtime: Cconws("\r\nIllegal time (bad format or out of range)\r\n"); return 1; } dodate(s) register char *s; { register int len; register int month,day,year; len = strlen(s); if (len != 6) goto baddate; month = (s[0]-'0') * 10 + (s[1]-'0'); day = (s[2]-'0') * 10 + (s[3]-'0'); year = ( s[4]-'0') * 10 + (s[5]-'0') - 80; if (year < 0 || year > 119 || month < 1 || month > 12 || day < 1 || day > 31) goto baddate; /* out of range */ if (!Tsetdate((year << 9) + (month << 5) + day)) return 0; baddate: Cconws("\r\nIllegal date (bad format or out of range)\r\n"); return 1; } strlen(s) register char *s; { register int i; for (i=0; *s++; i++) ; return i; } /***************************** cut here for settime.prg ******************/ begin 644 settime.prg M8!H```.&````F`````0``````````````````$Y6__)(YQ\$*FX`"$'M`($M M2/_R$"T`@$B`2,#0KO_R($!"$&`$4J[_\B!N__(,$``@9_(@;O_R2A!F8CZ\ M`!=.N0```U8N`"`''!5(AMQ\_]#-_``*$"T``4B`W$#/_0&BT``DB%VGS_T,O\``H0 M+0`#2(#:0-I\_]"^?``&9AP8+0`$2(38?/_0R?P`"A`M``5(@-A`V'S_T&`" M0D1*1FU"O'P`%VX\2D5M.+I\`#MN,DI$;2ZX?``[;B@P!G(+XV`^@#`%ZT#1 M5S`$XD#15S\\`"U.N0```W94CTJ`9@1"0&`4+KP```/!/SP`"4ZY```#=E2/ M<`%*GTS?(/!.7DYU3E8``$CG'P0J;@`(+HUA``"^/@"^?``&9@``EAP52(;< M?/_0S?P`"A`M``%(@-Q`W'S_T!HM``)(A=I\_]#+_``*$"T``TB`VD#:?/_0 M&"T`!$B$V'S_T,G\``H0+0`%2(#80-A\_X!*1&U$N'P`=VX^O'P``6TXO'P` M#&XRNGP``6TLNGP`'VXF,`1R">-@/H`P!NM`T5 3G5.5@``2.<# M!"IN``A"1V`"4D=*'6;Z,`=*GTS?((!.7DYU(]\```0>3DXO.0``!!Y.=2/? M```$'DY-+SD```0>3G4CWP``!!Y.02\Y```$'DYU16YT97(@=&AE('1I;64@ M*&AH;6U;
2DZ(``-"@`- M"DEL;&5G86P@=&EM92`H8F%D(&9O