void set_systime(systime_t *time)
{
struct tm my_tm;
time_t t1;
// char buf[128] = {0};
/**********************************************************
sprintf(buf, "%04d-%02d-%02d %02d:%02d:%02d",time->year,
time->month, time->day, time->hour, time->minute, time->millionsecond);
printf("%s\n", buf); //2012-12-12 12:12:12
***********************************************************/
my_tm.tm_year = time->year - 1900;
my_tm.tm_mon = time->month - 1;
my_tm.tm_mday = time->day;
my_tm.tm_hour = time->hour;
my_tm.tm_min = time->minute;
my_tm.tm_sec = time->millionsecond/1000;
/**********************************************************
sprintf(buf, "%04d-%02d-%02d %02d:%02d:%02d",my_tm.tm_year + 1900,
my_tm.tm_mon + 1, my_tm.tm_mday, my_tm.tm_hour, my_tm.tm_min, my_tm.tm_sec);
printf("%s\n", buf); //2012-12-12 12:12:12
*************************************************************/
t1 = mktime(&my_tm);
stime(&t1);
}
void get_systime(systime_t *mytime)
{
struct tm *my_tm;
time_t t1;
t1 = time(&t1);
my_tm = localtime(&t1);
mytime->year = my_tm->tm_year + 1900;
mytime->month = my_tm->tm_mon + 1;
mytime->day = my_tm->tm_mday;
mytime->hour = my_tm->tm_hour;
mytime->minute = my_tm->tm_min;
mytime->millionsecond = my_tm->tm_sec * 1000;
}