![]() |
|
| << Previous | Next >> | |
| | |
Description
- Sets the system time from a
tmstruct. It is important to note that althoughtm_rd()reads theSEC_TIMERvariable, not the RTC,tm_wr()writes to the RTC directly, andSEC_TIMERis not changed until the program is restarted. The reason for this is so that theDelaySec()function continues to work correctly after setting the system time. To maketm_rd()match the new time written to the RTC without restarting the program, the following should be done:tm_wr(tm);
SEC_TIMER = mktime(tm);
- But this could cause problems if a
waitfor(DelaySec(n))is pending completion in a cooperative multitasking program or if theSEC_TIMERvariable is being used in another way the user, so user beware.Parameters
- t
- Pointer to structure to read date and time from.
struct tm {
char tm_sec; // seconds 0-59
char tm_min; // 0-59
char tm_hour; // 0-23
char tm_mday; // 1-31
char tm_mon; // 1-12
char tm_year; // 80-147 (1980-2047)
char tm_wday; // 0-6 0==Sunday
};Return value
0: Success .
-1: Failure.Library
- RTCLOCK.LIB
See also
- mktm, mktime, tm_rd
| Dynamic C Functions | << Previous | Next >> | rabbit.com |