mirror of
https://github.com/AsgardEternal/squad-js-map-vote.git
synced 2025-01-24 00:13:52 -06:00
utc time support
This commit is contained in:
parent
5c3cc0e71e
commit
9024ec0945
14
README.MD
14
README.MD
@ -125,6 +125,18 @@ Array of timeframes that allows to override options based on local time. See exa
|
|||||||
```json
|
```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
|
### Example configuration
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@ -149,6 +161,7 @@ Array of timeframes that allows to override options based on local time. See exa
|
|||||||
"name": "follow layer rotation list",
|
"name": "follow layer rotation list",
|
||||||
"start": "12:00",
|
"start": "12:00",
|
||||||
"end": "18:00",
|
"end": "18:00",
|
||||||
|
"utcTime": true,
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"automaticVoteStart": false
|
"automaticVoteStart": false
|
||||||
}
|
}
|
||||||
@ -156,6 +169,7 @@ Array of timeframes that allows to override options based on local time. See exa
|
|||||||
{
|
{
|
||||||
"start": "22:00",
|
"start": "22:00",
|
||||||
"end": "02:00",
|
"end": "02:00",
|
||||||
|
"utcTime": false,
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"voteBroadcastMessage": "Late night games? Vote your favourite map!"
|
"voteBroadcastMessage": "Late night games? Vote your favourite map!"
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,6 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
this.updateNextMap();
|
this.updateNextMap();
|
||||||
}
|
}
|
||||||
async timeframeOptionOverrider() {
|
async timeframeOptionOverrider() {
|
||||||
const timeNow = new Date(0, 0, 0, new Date().getHours(), new Date().getMinutes());
|
|
||||||
const activeTimeframes = this.or_options.timeFrames.filter(tfFilter);
|
const activeTimeframes = this.or_options.timeFrames.filter(tfFilter);
|
||||||
|
|
||||||
let logTimeframe = "Active Time Frames: ";
|
let logTimeframe = "Active Time Frames: ";
|
||||||
@ -184,13 +183,15 @@ export default class MapVote extends DiscordBasePlugin {
|
|||||||
for (let atfK in activeTimeframes) {
|
for (let atfK in activeTimeframes) {
|
||||||
const atf = activeTimeframes[ atfK ];
|
const atf = activeTimeframes[ atfK ];
|
||||||
activeTfIds.push(atf.name || atf.id);
|
activeTfIds.push(atf.name || atf.id);
|
||||||
for(let o in atf.overrides){
|
for (let o in atf.overrides) {
|
||||||
this.options[o] = atf.overrides[o];
|
this.options[ o ] = atf.overrides[ o ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.verbose(1, logTimeframe + activeTfIds.join(', '));
|
this.verbose(1, logTimeframe + activeTfIds.join(', '));
|
||||||
|
|
||||||
function tfFilter(tf, key, arr) {
|
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;
|
arr[ key ].id = key + 1;
|
||||||
const tfStartSplit = [ parseInt(tf.start.split(':')[ 0 ]), parseInt(tf.start.split(':')[ 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 ]) ];
|
const tfEndSplit = [ parseInt(tf.end.split(':')[ 0 ]), parseInt(tf.end.split(':')[ 1 ]) ];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user