This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// Rules: start and end in 24h format, interval in minutes
|
||||
const scheduleRules = [
|
||||
export const scheduleRules = [
|
||||
{ start: "0:00", end: "3:00", interval: 180 },
|
||||
{ start: "3:00", end: "4:00", interval: 60 },
|
||||
{ start: "5:00", end: "6:00", interval: 30 },
|
||||
@@ -9,12 +9,12 @@ const scheduleRules = [
|
||||
{ start: "19:00", end: "0:00", interval: 180 }
|
||||
];
|
||||
|
||||
function toMinutes(timeStr) {
|
||||
export function toMinutes(timeStr) {
|
||||
const [h, m] = timeStr.split(":").map(Number);
|
||||
return h * 60 + (m || 0);
|
||||
}
|
||||
|
||||
function getCurrentInterval(date = new Date()) {
|
||||
export function getCurrentInterval(date = new Date()) {
|
||||
const nowMinutes = date.getHours() * 60 + date.getMinutes();
|
||||
|
||||
for (const rule of scheduleRules) {
|
||||
@@ -35,9 +35,3 @@ function getCurrentInterval(date = new Date()) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
scheduleRules,
|
||||
getCurrentInterval,
|
||||
toMinutes
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user