mirror of
https://github.com/Frail7487Real/laughing-spork.git
synced 2024-11-14 10:55:10 -05:00
ok this should fix chadGPT's retarded code
This commit is contained in:
parent
bfb7183d7b
commit
7d8c55fe07
2 changed files with 8 additions and 27 deletions
33
checkTime.js
33
checkTime.js
|
@ -1,32 +1,13 @@
|
||||||
const { match } = require('assert')
|
|
||||||
const process = require('process')
|
|
||||||
|
|
||||||
if (process.argv.length < 3) {
|
|
||||||
console.error('Invalid format. Expected HH:MM')
|
|
||||||
process.exit(69)
|
|
||||||
}
|
|
||||||
|
|
||||||
const startTimeString = process.argv[2]
|
const startTimeString = process.argv[2]
|
||||||
const [startHours, startMinutes] = startTimeString.split(':').map(Number)
|
const [startDate, startMonth, startYear, startHours, startMinutes] = startTimeString.split(':').map(Number)
|
||||||
|
|
||||||
if (
|
const targetTime = new Date()
|
||||||
isNaN(startHours) || isNaN(startMinutes) ||
|
targetTime.setUTCFullYear(startYear, startMonth - 1, startDate)
|
||||||
startHours > 23 || startMinutes > 59
|
targetTime.setUTCHours(startHours + 5, startMinutes, 0, 0)
|
||||||
) {
|
|
||||||
console.error('Invalid time format. Expected HH:MM format WITH VALID TIME')
|
|
||||||
process.exit(69)
|
|
||||||
}
|
|
||||||
|
|
||||||
const startTime = new Date()
|
|
||||||
startTime.setHours(startHours, startMinutes, 0, 0)
|
|
||||||
|
|
||||||
const targetTime = new Date(startTime.getTime() + 5 * 60 * 60 * 1000) // 5 hours after startTime
|
|
||||||
targetTime.setSeconds(0) // fixes the precise time, we don't want them
|
|
||||||
targetTime.setMilliseconds(0)
|
|
||||||
|
|
||||||
const currentTime = new Date()
|
const currentTime = new Date()
|
||||||
currentTime.setSeconds(0)
|
currentTime.setUTCSeconds(0) // we don't want precise time
|
||||||
currentTime.setMilliseconds(0)
|
currentTime.setUTCMilliseconds(0)
|
||||||
|
|
||||||
if (currentTime.getTime() === targetTime.getTime()) {
|
if (currentTime.getTime() === targetTime.getTime()) {
|
||||||
console.log('[checkTime] time matches, now exiting with status 0 to make another runtime')
|
console.log('[checkTime] time matches, now exiting with status 0 to make another runtime')
|
||||||
|
@ -34,6 +15,6 @@ if (currentTime.getTime() === targetTime.getTime()) {
|
||||||
} else {
|
} else {
|
||||||
console.log('[checkTime] time doesn\'t match')
|
console.log('[checkTime] time doesn\'t match')
|
||||||
console.log(`currentTime is ${currentTime}`)
|
console.log(`currentTime is ${currentTime}`)
|
||||||
console.log(`targetTiem is ${targetTime}`)
|
console.log(`targetTime is ${targetTime}`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
2
loop.sh
2
loop.sh
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
START_TIME=$(date +"%H:%M") # the checkTime.js script uses local time
|
START_TIME=$(TZ=Etc/UTC date +"%d:%m:%Y:%H:%M") # the checkTime.js script uses local time
|
||||||
|
|
||||||
GH_TOKEN=$2
|
GH_TOKEN=$2
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue