/* Peter Mauzey copied most of this code from nbs_time.c, which is part of NISTime_cpio.Z, Nov 6 1989 07:42, for the AT&T UNIX PC, 7300. The README includes: Robert A. Brown, (303) 538-4749, {ihnp4|hogpc}!druhi!rafb AT&T Bell Laboratories 12110 N. Pecos St., Room: DN 8Z326 Denver, CO 80234 */ #include #include #include #include long set_rtc(); main() { set_rtc(); /* Set the system clock on this machine. */ } long set_rtc() { long cur_time; /* current time on software clock */ struct rtc rtc; /* structure for setting real time clock */ struct tm *tm; /* pointer to localtime() structure */ /* now set the hardware clock */ (void)time(&cur_time); tm = localtime(&cur_time); /* convert time to local time */ rtc.wkday = tm->tm_wday; rtc.yr10 = tm->tm_year / 10; rtc.yr1 = tm->tm_year % 10; rtc.mon10 = (tm->tm_mon + 1) / 10; rtc.mon1 = (tm->tm_mon + 1) % 10; rtc.day10 = tm->tm_mday / 10; rtc.day1 = tm->tm_mday % 10; rtc.hr10 = tm->tm_hour / 10; rtc.hr1 = tm->tm_hour % 10; rtc.min10 = tm->tm_min / 10; rtc.min1 = tm->tm_min % 10; rtc.sec10 = tm->tm_sec / 10; rtc.sec1 = tm->tm_sec % 10; (void)syslocal(SYSL_WRTRTC, &rtc); /* write to RTC */ return; }