我需要根据时间在文本视图上设置文本。如果不平等在一天之内(从 5:00 到 7:30),我使用:
if (today.month == 7 &&
today.monthDay == 7 &&
(today.hour > 5 || (today.hour == 5 && today.minute >= 00)) &&
(today.hour < 7 || (today.hour == 7 && today.minute <= 30)))
{DubAcademy.setText("A");}
问题是这段代码在从一天到下一天的几个小时内都不起作用(即第二天的 23:00 到 1:00)。我试过这个,但没有工作
if (today.month == 7 &&
today.monthDay == 6 &&
(today.hour > 23 || (today.hour == 23 && today.minute >= 00)) &&
(today.monthDay <= 7 || (today.monthDay == 7 && today.hour <= 01 && today.minute <= 00 )))
{DubAcademy.setText("B");}
我知道这是因为月份日期设置为 6,因此,当日期更改时,等式不再有效并且不显示文本。
有任何想法吗?