好的,我有以下代码:
if (!clock_is_24h_style()) {
if (current_time->tm_hour <= 3)
set_container_image(&time_format_image, RESOURCE_ID_NBC, GPoint(0, 0));
else if (current_time->tm_hour == 4 && current_time->tm_min <= 29)
set_container_image(&time_format_image, RESOURCE_ID_ETODAY, GPoint(0, 0));
else if (current_time->tm_hour == 4 && current_time->tm_min >= 30)
set_container_image(&time_format_image, RESOURCE_ID_9NEWSMORN, GPoint(0, 0));
else if (current_time->tm_hour == 5)
set_container_image(&time_format_image, RESOURCE_ID_9NEWSMORN, GPoint(0, 0));
else if (current_time->tm_hour == 6)
set_container_image(&time_format_image, RESOURCE_ID_9NEWSMORN, GPoint(0, 0));
else if (current_time->tm_hour == 12 && current_time->tm_min <= 29)
set_container_image(&time_format_image, RESOURCE_ID_IMAGE_PM_MODE, GPoint(0, 0));
else if (current_time->tm_hour == 12 && current_time->tm_min >= 30)
set_container_image(&time_format_image, RESOURCE_ID_NBC, GPoint(0, 0));
else if (current_time->tm_hour == 13 && current_time->tm_min <= 29)
set_container_image(&time_format_image, RESOURCE_ID_WTC, GPoint(0, 0));
else if (current_time->tm_hour == 13 && current_time->tm_min >= 30)
set_container_image(&time_format_image, RESOURCE_ID_BEARS, GPoint(0, 0));
else if (current_time->tm_hour == 14 && current_time->tm_min <= 29)
set_container_image(&time_format_image, RESOURCE_ID_WTC, GPoint(0, 0));
else if (current_time->tm_hour == 14 && current_time->tm_min >= 30)
set_container_image(&time_format_image, RESOURCE_ID_BEARS, GPoint(0, 0));
else if (current_time->tm_hour == 15)
set_container_image(&time_format_image, RESOURCE_ID_NBC, GPoint(0, 0));
else if (current_time->tm_hour == 16)
set_container_image(&time_format_image, RESOURCE_ID_9NEWS4, GPoint(0, 0));
else if (current_time->tm_hour == 17)
set_container_image(&time_format_image, RESOURCE_ID_9NEWS5, GPoint(0, 0));
else if (current_time->tm_hour == 18 && current_time->tm_min <= 29)
set_container_image(&time_format_image, RESOURCE_ID_9NEWS6, GPoint(0, 0));
else if (current_time->tm_hour == 18 && current_time->tm_min >= 30)
set_container_image(&time_format_image, RESOURCE_ID_NN, GPoint(0, 0));
else if (current_time->tm_hour == 19)
set_container_image(&time_format_image, RESOURCE_ID_NBC, GPoint(0, 0));
else if (current_time->tm_hour == 20)
set_container_image(&time_format_image, RESOURCE_ID_WTC, GPoint(0, 0));
else if (current_time->tm_hour == 21)
set_container_image(&time_format_image, RESOURCE_ID_BEARS, GPoint(0, 0));
else if (current_time->tm_hour == 22)
set_container_image(&time_format_image, RESOURCE_ID_NBC, GPoint(0, 0));
else if (current_time->tm_hour == 23 && current_time->tm_min <= 34)
set_container_image(&time_format_image, RESOURCE_ID_9NEWS10, GPoint(0, 0));
else if (current_time->tm_hour >= 23 && current_time->tm_min >= 35)
set_container_image(&time_format_image, RESOURCE_ID_NBC, GPoint(0, 0));
else {
layer_remove_from_parent(&time_format_image.layer.layer);
bmp_deinit_container(&time_format_image);
}
这使得手表上的图像在某个时间发生变化,这很棒,而且效果很棒。
但是,代码每天都会循环播放,并且每天都在制作,并且它在工作日(星期一到星期五)唯一准确,并且想知道如何才能使代码仅适用于周一至周五,而单独的代码适用于星期六,另一个适用于星期日。谢谢!
答案 0 :(得分:4)
struct tm
包含保存星期几的成员tm_wday
,其中0表示星期日,6表示星期六。
答案 1 :(得分:0)
您是否可以封装您的工作日图像更改代码,以便您可以创建一组星期六图像更改代码和星期日图像更改代码,然后在进入此例程时分支到正确的图像更改代码集通过确定星期几然后适当分支。