時報休止期間を修正・package.jsonの情報を修正・v4.2

This commit is contained in:
Last2014 2025-07-05 11:46:43 +09:00
parent 678f4aa1b1
commit c3ab3a8456
4 changed files with 20 additions and 15 deletions

View File

@ -6,8 +6,8 @@ const config: configTypes = {
time: {
// 時報休止期間
stopTimes: {
start: new Date("23:00"), // 開始
stop: new Date("6:00"), // 停止
start: 23, // 開始
stop: 6, // 停止
}
},
// 地震速報設定

View File

@ -1,6 +1,6 @@
{
"name": "noticeuwuzu",
"version": "v4.1.2@uwuzu1.5.4",
"version": "v4.2@uwuzu1.5.4",
"description": "uwuzu Notice Bot",
"main": "dist/main.js",
"scripts": {
@ -12,16 +12,17 @@
"uwuzu",
"bot",
"cron",
"notice",
"weather",
"time",
"timenotice",
"notice"
"earthquake"
],
"author": {
"name": "Last2014",
"url": "https://last2014.com",
"email": "info@last2014.com"
},
"license": "ISC",
"license": "Apache-2.0",
"type": "module",
"dependencies": {
"@types/date-fns": "^2.5.3",

View File

@ -1,20 +1,24 @@
import { format, isAfter, isBefore } from "date-fns";
import { format } from "date-fns";
import type * as types from "types/types";
import config from "../config.js";
// 停止時間
// 時刻取得
const now = new Date();
const start = config.time.stopTimes.start;
const stop = config.time.stopTimes.stop;
// 停止時刻外
let inRange: Boolean = false;
// 現在の時間を取得
const nowHour = new Date().getHours();
if (isBefore(start, stop)) {
inRange = isAfter(now, start) && isBefore(now, stop);
// 停止時刻内かどうかの判定
let inRange: boolean = false;
if (start < stop) {
inRange = nowHour >= start && nowHour < stop;
} else {
inRange = isAfter(now, start) || isBefore(now, stop);
inRange = nowHour >= start || nowHour < stop;
}

4
types/config.d.ts vendored
View File

@ -11,8 +11,8 @@ interface weatherTypes {
}
interface stopsTypes {
start: Date;
stop: Date;
start: number;
stop: number;
}
interface timeTypes {