Xref: utzoo unix-pc.general:1720 comp.sys.att:4802 Path: utzoo!utgpu!watmath!uunet!portal!cup.portal.com!thad From: thad@cup.portal.com (Thad P Floryan) Newsgroups: unix-pc.general,comp.sys.att Subject: Re: syslocal(2) on 3b1 sick? Message-ID: <11748@cup.portal.com> Date: 25 Nov 88 01:19:39 GMT References: <130@zebra.UUCP> Organization: The Portal System (TM) Lines: 55 Re: handling the UNIXpc's real-time clock, following is some code that WORKS, extracted from a program I'll be posting to unix-pc.sources in the near future. Enjoy! Thad Floryan [ thad@cup.portal.com (OR) ..!sun!portal!cup.portal.com!thad ] ======================================== #include #include #include #ifdef UNIXPC #include #include #endif . . #ifdef UNIXPC /* Sets the battery-backed Real Time Clock in the UNIXpc to the same * date and time values as the system clock. */ set_rtc(tval) time_t tval; { struct tm *p_tm; struct rtc rtc_s; struct rtc *p_rtc; p_tm = localtime(&tval); p_rtc = &rtc_s; p_rtc->wkday = p_tm->tm_wday; p_rtc->yr10 = p_tm->tm_year / 10; p_rtc->yr1 = p_tm->tm_year % 10; p_rtc->mon10 = (p_tm->tm_mon + 1) / 10; p_rtc->mon1 = (p_tm->tm_mon + 1) % 10; p_rtc->day10 = p_tm->tm_mday / 10; p_rtc->day1 = p_tm->tm_mday % 10; p_rtc->hr10 = p_tm->tm_hour / 10; p_rtc->hr1 = p_tm->tm_hour % 10; p_rtc->min10 = p_tm->tm_min / 10; p_rtc->min1 = p_tm->tm_min % 10; p_rtc->sec10 = p_tm->tm_sec / 10; p_rtc->sec1 = p_tm->tm_sec % 10; syslocal(SYSL_WRTRTC, p_rtc); /* write to RTC */ } #endif