显示时间Time_Display():
void Time_Display(uint32_t TimeVar,struct rct_time *tm)
{
static uint32_t FirstDisplay = 1;
uint32_t BJ_TimeVar;
uint8_t str[15]; // 字符串暂存
/* 把标准时间转换为北京时间*/
BJ_TimeVar =TimeVar + 8*60*60;
/*利用时间戳转换为北京时间*/
to_tm(BJ_TimeVar, tm);
if((!tm->tm_hour && !tm->tm_min && !tm->tm_sec) || (FirstDisplay))
{
GetChinaCalendar((u16)tm->tm_year, (u8)tm->tm_mon, (u8)tm->tm_mday, str);
printf("\r\n\r\n 今天农历:%0.2d%0.2d,%0.2d,%0.2d", str[0], str[1], str[2], str[3]);
GetChinaCalendarStr((u16)tm->tm_year,(u8)tm->tm_mon,(u8)tm->tm_mday,str);
printf(" %s", str);
if(GetJieQiStr((u16)tm->tm_year, (u8)tm->tm_mon, (u8)tm->tm_mday, str))
{
printf(" %s\n\r", str);
}
FirstDisplay = 0;
}
printf("\r UNIX 时间戳 = %d ,当前时间为: %d 年(%s 年) %d 月 %d日 (星期%s) %0.2d:%0.2d:%0.2d",TimeVar,tm->tm_year, zodiac_sign[(tm->tm_year-3)%12], tm->tm_mon, tm->tm_mday,WEEK_STR[tm->tm_wday], tm->tm_hour,tm->tm_min, tm->tm_sec);
}
|