translator, wb_editors
4218
правок
Matveevrj (обсуждение | вклад) (Новая страница: «There should be no error messages in the log (exit via control-c)») |
Matveevrj (обсуждение | вклад) (Новая страница: «4. Describe the virtual device in the file») |
||
Строка 941: | Строка 941: | ||
(function(Schedules) { // closing | (function(Schedules) { // closing | ||
function todayAt(now, hours, minutes) { | |||
function todayAt(now, hours, minutes) { | |||
var date = new Date(now); | var date = new Date(now); | ||
// i.e. "today, at HH:MM". All dates are in UTC! | // i.e. "today, at HH:MM". All dates are in UTC! | ||
Строка 949: | Строка 948: | ||
return date; | return date; | ||
} | } | ||
function checkScheduleInterval(now, start_time, end_time) { | |||
function checkScheduleInterval(now, start_time, end_time) { | |||
var start_date = todayAt(now, start_time[0], start_time[1]); | var start_date = todayAt(now, start_time[0], start_time[1]); | ||
var end_date = todayAt(now, end_time[0], end_time[1]); | var end_date = todayAt(now, end_time[0], end_time[1]); | ||
log("checkScheduleInterval {} {} {}".format(now, start_date, end_date)); | log("checkScheduleInterval {} {} {}".format(now, start_date, end_date)); | ||
if (end_date >= start_date) { | |||
if (end_date >= start_date) { | |||
if ((now >= start_date) && (now < end_date)) { | if ((now >= start_date) && (now < end_date)) { | ||
return true; | return true; | ||
Строка 966: | Строка 961: | ||
// end date is less than start date, | // end date is less than start date, | ||
// assuming they belong to a different days (e.g. today and tomorrow) | // assuming they belong to a different days (e.g. today and tomorrow) | ||
// option 1: what if it's now the day of "end" date? | |||
// option 1: what if it's now the day of "end" date? | |||
// in this case the following is enough: | // in this case the following is enough: | ||
if (now < end_date) { | if (now < end_date) { | ||
return true; | return true; | ||
} | } | ||
// well, that seems not to be the case. ok, | |||
// well, that seems not to be the case. ok, | |||
// option 2: it's the day of "start" date: | // option 2: it's the day of "start" date: | ||
if (now >= start_date) { | |||
if (now >= start_date) { | |||
return true; | return true; | ||
} | } | ||
} | } | ||
return false; | return false; | ||
<div lang="ru" dir="ltr" class="mw-content-ltr"> | <div lang="ru" dir="ltr" class="mw-content-ltr"> |