1
매일 8시에 vibe.d 웹 앱에서 작업을 실행하려고합니다. 지금은 정기 매개 변수가 true
인 setTimer
함수를 사용합니다. 하지만 이렇게하면 작업이 트리거되는 시간을 정확하게 제어 할 수 없습니다. 진동으로이 작업을 수행하는 쉬운 방법이 있습니까?매일 오전 8:00에 진동으로 작업을 실행하는 방법이 있습니까?
매일 8시에 vibe.d 웹 앱에서 작업을 실행하려고합니다. 지금은 정기 매개 변수가 true
인 setTimer
함수를 사용합니다. 하지만 이렇게하면 작업이 트리거되는 시간을 정확하게 제어 할 수 없습니다. 진동으로이 작업을 수행하는 쉬운 방법이 있습니까?매일 오전 8:00에 진동으로 작업을 실행하는 방법이 있습니까?
감사합니다. sigod, 정확히 내가 한 일입니다. 다음 8 시까 지 시간을 계산하고 setTimer를 호출합니다. 다음은 참조 용 코드입니다.
void startDailyTaskAtTime(TimeOfDay time, void delegate() task) {
// Get the current date and time
DateTime now = cast(DateTime)Clock.currTime();
// Get the next time occurrence
DateTime nextOcc = cast(DateTime)now;
if (now.timeOfDay >= time) {
nextOcc += dur!"days"(1);
}
nextOcc.timeOfDay = time;
// Get the duration before now and the next occurrence
Duration timeBeforeNextOcc = nextOcc - now;
void setDailyTask() {
// Run the task once
task();
// Run the task all subsequent days at the same time
setTimer(1.days, task, true);
}
setTimer(timeBeforeNextOcc, &setDailyTask);
}
다음 오전 8 시까 지 시간을 계산하지 않고 적절한 시간 동안 'setTimer'를 호출하지 못하도록하는 내용이 없습니다. – sigod