void rtc_set_currtime (const char* seconds) { struct tm *time; unsigned long epoch; time_t _tt; epoch = atol (seconds); _tt = (time_t)epoch; time = gmtime (&_tt); write_rtc_time ((struct rtc_time *)time); }
/* * Write the specified time into the clock chip. * Must be called with tod_lock held. */ static void todbq4802_set(timestruc_t ts) { struct rtc_t rtc; todinfo_t tod = utc_to_tod(ts.tv_sec); int year; ASSERT(MUTEX_HELD(&tod_lock)); /* tod_year is base 1900 so this code needs to adjust */ year = 1900 + tod.tod_year; rtc.rtc_year = year % 100; rtc.rtc_century = year / 100; rtc.rtc_mon = (uint8_t)tod.tod_month; rtc.rtc_dom = (uint8_t)tod.tod_day; rtc.rtc_dow = (uint8_t)tod.tod_dow; rtc.rtc_hrs = (uint8_t)tod.tod_hour; rtc.rtc_min = (uint8_t)tod.tod_min; rtc.rtc_sec = (uint8_t)tod.tod_sec; DPRINTF("todbq4802_set: year=%d dom=%d hrs=%d min=%d sec=%d\n", rtc.rtc_year, rtc.rtc_dom, rtc.rtc_hrs, rtc.rtc_min, rtc.rtc_sec); write_rtc_time(&rtc); }