mirror of
https://github.com/oopuuu/zTC1.git
synced 2025-12-12 13:08:13 +08:00
添加星期任务成功
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
pTimedTask task_top = NULL;
|
pTimedTask task_top = NULL;
|
||||||
int task_count = 0;
|
int task_count = 0;
|
||||||
|
|
||||||
bool AddTask(pTimedTask task)
|
bool AddTaskSingle(pTimedTask task)
|
||||||
{
|
{
|
||||||
task_count++;
|
task_count++;
|
||||||
if (task_top == NULL)
|
if (task_top == NULL)
|
||||||
@@ -42,6 +42,24 @@ bool AddTask(pTimedTask task)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AddTaskWeek(pTimedTask task)
|
||||||
|
{
|
||||||
|
int day_sec = 86400;
|
||||||
|
time_t now = time(NULL);
|
||||||
|
int today_weekday = (now / day_sec + 3) % 7 + 1; //1970-01-01 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
int next_day = task->weekday - today_weekday;
|
||||||
|
next_day = next_day > 0 ? next_day : next_day + 7;
|
||||||
|
task->prs_time = (now - now % day_sec) + (next_day * day_sec) + task->prs_time % day_sec;
|
||||||
|
|
||||||
|
return AddTaskSingle(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AddTask(pTimedTask task)
|
||||||
|
{
|
||||||
|
if (task->weekday == 0) return AddTaskSingle(task);
|
||||||
|
return AddTaskWeek(task);
|
||||||
|
}
|
||||||
|
|
||||||
bool DelFirstTask()
|
bool DelFirstTask()
|
||||||
{
|
{
|
||||||
if (task_top)
|
if (task_top)
|
||||||
|
|||||||
Reference in New Issue
Block a user