function workHours(on, off, testNow = null) {
// TODO: validate input
const now = testNow ?? new Date().getHours();
const a = Number(on);
let b = Number(off);
const format = (status, nextTime) => ({ status, next_time: nextTime });
if (a === b) {
return format(true, 0);
}
if (a > b) {
b += 24;
}
if (now >= a && now < b) {
return format(true, 0);
}
if (now < a) {
return format(false, a - now);
}
return format(false, a + 24 - now);
}
// Тесты тесты
const tests = [
[9, 17, 10, { status: true, next_time: 0 }],
[9, 17, 8, { status: false, next_time: 1 }],
[9, 17, 17, { status: false, next_time: 16 }],
[19, 17, 17, { status: false, next_time: 2 }],
[19, 19, 17, { status: true, next_time: 0 }],
];
const eq = (a, b) => Object.entries(a).every(([k, v]) => b[k] === v);
tests.forEach(test => {
const [on, off, now, expected] = test;
const result = workHours(on, off, now);
const testResult = eq(result, expected);
if (testResult) {
console.log('Passed', {on, off, now, result});
}
console.assert(testResult, test);
});
background.js
выполнить:await chrome.proxy.settings.set(
{
value: {
mode: 'pac_script',
pacScript: {
data: 'function FindProxyForURL(url, host) { return "DIRECT"; }'
}
},
scope: 'regular'
}
);
from flask import Flask, request
app = Flask(__name__)
@app.route('/', methods=['POST'])
def hello_world():
result = request.form.get('login')
return result*2
if __name__ == '__main__':
app.run()
$.ajax({
url: "http://127.0.0.1:5000",
type: "POST",
cache: false,
data: {'login' : 'brepex'},
success: (data) => {
alert(data)
}
});
FOR %F IN ("%SystemRoot%\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientTools-Package~*.mum") DO (DISM /Online /NoRestart /Add-Package:"%F")
FOR %F IN ("%SystemRoot%\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientExtensions-Package~*.mum") DO (DISM /Online /NoRestart /Add-Package:"%F")
Подскажите, в чем может быть проблема? Спасибо!!!Подсказываю: Файлы хранятся в файловой системе. Хранить файлы в бд это палка о двух концах, оба из которых засунуты в ж...
time.time()-(60*60*24)
time_day_before = time()-(60*60*24)
n = 0
for x in lst:
if x < time_day_before:
break
n += 1
print(n)