utc time support

This commit is contained in:
Davide Fantino 2022-09-18 14:19:22 +02:00
parent 5c3cc0e71e
commit 9024ec0945
2 changed files with 18 additions and 3 deletions

View File

@ -125,6 +125,18 @@ Array of timeframes that allows to override options based on local time. See exa
```json
[]
```
###### Timeframe format
```javascript
{
"name": "friendly name", // a friendly name visible in the logs
"start": "12:00", // timeframe start time <hour>:<minutes>
"end": "18:00", // timeframe end time <hour>:<minutes>
"utcTime": true, // true: use UTC time; false: use LOCAL time
"overrides": {
"automaticVoteStart": false
}
},
```
### Example configuration
```json
{
@ -149,6 +161,7 @@ Array of timeframes that allows to override options based on local time. See exa
"name": "follow layer rotation list",
"start": "12:00",
"end": "18:00",
"utcTime": true,
"overrides": {
"automaticVoteStart": false
}
@ -156,6 +169,7 @@ Array of timeframes that allows to override options based on local time. See exa
{
"start": "22:00",
"end": "02:00",
"utcTime": false,
"overrides": {
"voteBroadcastMessage": "Late night games? Vote your favourite map!"
}

View File

@ -175,7 +175,6 @@ export default class MapVote extends DiscordBasePlugin {
this.updateNextMap();
}
async timeframeOptionOverrider() {
const timeNow = new Date(0, 0, 0, new Date().getHours(), new Date().getMinutes());
const activeTimeframes = this.or_options.timeFrames.filter(tfFilter);
let logTimeframe = "Active Time Frames: ";
@ -184,13 +183,15 @@ export default class MapVote extends DiscordBasePlugin {
for (let atfK in activeTimeframes) {
const atf = activeTimeframes[ atfK ];
activeTfIds.push(atf.name || atf.id);
for(let o in atf.overrides){
this.options[o] = atf.overrides[o];
for (let o in atf.overrides) {
this.options[ o ] = atf.overrides[ o ];
}
}
this.verbose(1, logTimeframe + activeTfIds.join(', '));
function tfFilter(tf, key, arr) {
const timeNow = tf.utcTime?new Date(0, 0, 0, new Date().getUTCHours(), new Date().getUTCMinutes()):new Date(0, 0, 0, new Date().getHours(), new Date().getMinutes());
arr[ key ].id = key + 1;
const tfStartSplit = [ parseInt(tf.start.split(':')[ 0 ]), parseInt(tf.start.split(':')[ 1 ]) ];
const tfEndSplit = [ parseInt(tf.end.split(':')[ 0 ]), parseInt(tf.end.split(':')[ 1 ]) ];