時報休止期間を修正・package.jsonの情報を修正・v4.2
This commit is contained in:
parent
678f4aa1b1
commit
c3ab3a8456
|
@ -6,8 +6,8 @@ const config: configTypes = {
|
||||||
time: {
|
time: {
|
||||||
// 時報休止期間
|
// 時報休止期間
|
||||||
stopTimes: {
|
stopTimes: {
|
||||||
start: new Date("23:00"), // 開始
|
start: 23, // 開始
|
||||||
stop: new Date("6:00"), // 停止
|
stop: 6, // 停止
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 地震速報設定
|
// 地震速報設定
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "noticeuwuzu",
|
"name": "noticeuwuzu",
|
||||||
"version": "v4.1.2@uwuzu1.5.4",
|
"version": "v4.2@uwuzu1.5.4",
|
||||||
"description": "uwuzu Notice Bot",
|
"description": "uwuzu Notice Bot",
|
||||||
"main": "dist/main.js",
|
"main": "dist/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -12,16 +12,17 @@
|
||||||
"uwuzu",
|
"uwuzu",
|
||||||
"bot",
|
"bot",
|
||||||
"cron",
|
"cron",
|
||||||
|
"notice",
|
||||||
|
"weather",
|
||||||
"time",
|
"time",
|
||||||
"timenotice",
|
"earthquake"
|
||||||
"notice"
|
|
||||||
],
|
],
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Last2014",
|
"name": "Last2014",
|
||||||
"url": "https://last2014.com",
|
"url": "https://last2014.com",
|
||||||
"email": "info@last2014.com"
|
"email": "info@last2014.com"
|
||||||
},
|
},
|
||||||
"license": "ISC",
|
"license": "Apache-2.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/date-fns": "^2.5.3",
|
"@types/date-fns": "^2.5.3",
|
||||||
|
|
|
@ -1,20 +1,24 @@
|
||||||
import { format, isAfter, isBefore } from "date-fns";
|
import { format } from "date-fns";
|
||||||
|
|
||||||
import type * as types from "types/types";
|
import type * as types from "types/types";
|
||||||
import config from "../config.js";
|
import config from "../config.js";
|
||||||
|
|
||||||
|
|
||||||
|
// 停止時間
|
||||||
// 時刻取得
|
// 時刻取得
|
||||||
const now = new Date();
|
|
||||||
const start = config.time.stopTimes.start;
|
const start = config.time.stopTimes.start;
|
||||||
const stop = config.time.stopTimes.stop;
|
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 {
|
} else {
|
||||||
inRange = isAfter(now, start) || isBefore(now, stop);
|
inRange = nowHour >= start || nowHour < stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ interface weatherTypes {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface stopsTypes {
|
interface stopsTypes {
|
||||||
start: Date;
|
start: number;
|
||||||
stop: Date;
|
stop: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface timeTypes {
|
interface timeTypes {
|
||||||
|
|
Loading…
Reference in New Issue