1

好的,所以我有以下代码:

   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);
}

它使手表上的图像在特定时间发生变化,这很棒而且很棒。

但是,代码每天循环,并且每天都在制作,并且它仅在工作日(周一至周五)准确,并且想知道如何制作它以便代码仅适用于周一至周五,而单独的代码将适用到星期六和另一个星期天。谢谢!

4

2 回答 2

4

struct tm包含tm_wday星期几的成员,其中 0 是星期日,6 是星期六。

于 2013-06-08T20:58:28.123 回答
0

你能不能不封装你的工作日换像代码,这样你就可以创建一组周六换像代码和周日换像代码,然后在进入这个例程时通过确定星期几,然后适当地分支。

于 2013-06-08T21:00:24.453 回答