make content releases use a given offset to the time.

This commit is contained in:
Phillip Thelen
2024-05-29 19:05:17 +02:00
parent b501e06f27
commit 54b1afd5b4
8 changed files with 107 additions and 18 deletions
@@ -1,4 +1,5 @@
import moment from 'moment';
import nconf from 'nconf';
import SEASONAL_SETS from './seasonalSets';
import { getRepeatingEvents } from './events';
@@ -773,6 +774,8 @@ export const GALA_SCHEDULE = {
},
};
const SWITCHOVER_TIME = nconf.get('CONTENT_SWITCHOVER_TIME_OFFSET') || 0;
export const TYPE_SCHEDULE = {
timeTravelers: FIRST_RELEASE_DAY,
backgrounds: SECOND_RELEASE_DAY,
@@ -790,7 +793,9 @@ function getDay (date) {
if (date === undefined) {
return 0;
}
return date instanceof moment ? date.date() : date.getDate();
const checkDate = new Date(date.getTime());
checkDate.setHours(checkDate.getHours() - SWITCHOVER_TIME);
return checkDate.getDate();
}
function getMonth (date) {
@@ -871,7 +876,7 @@ function makeMatcherClass (date) {
function makeEndDate (checkedDate, matcher) {
let end = moment.utc(checkedDate);
end.date(TYPE_SCHEDULE[matcher.type]);
end.hour(0);
end.hour(SWITCHOVER_TIME);
end.minute(0);
end.second(0);
if (matcher.endMonth !== undefined) {
@@ -2,6 +2,7 @@ import defaults from 'lodash/defaults';
import find from 'lodash/find';
import forEach from 'lodash/forEach';
import moment from 'moment';
import nconf from 'nconf';
import upperFirst from 'lodash/upperFirst';
import { ownsItem } from '../gear-helper';
import { ATTRIBUTES } from '../../../constants';
@@ -1832,6 +1833,7 @@ const weapon = {
},
};
const SWITCHOVER_TIME = nconf.get('CONTENT_SWITCHOVER_TIME_OFFSET') || 0;
const releaseDay = 7;
const releaseDates = {
somethingSpooky: { year: 2023, month: 10 },
@@ -1888,7 +1890,7 @@ forEach({
function updateReleased (type) {
const today = moment();
const releaseDateEndPart = `${String(releaseDay).padStart(2, '0')}T08:00-0500`;
const releaseDateEndPart = `${String(releaseDay).padStart(2, '0')}T${String(SWITCHOVER_TIME).padStart(2, '0')}:00-0500`;
const returnType = {};
forEach(type, (gearItem, gearKey) => {
let released;
+6 -1
View File
@@ -1,10 +1,15 @@
import moment from 'moment';
import nconf from 'nconf';
const SWITCHOVER_TIME = nconf.get('CONTENT_SWITCHOVER_TIME_OFFSET') || 0;
function getDay (date) {
if (date === undefined) {
return 0;
}
return date instanceof moment ? date.date() : date.getDate();
const checkDate = new Date(date.getTime());
checkDate.setHours(checkDate.getHours() - SWITCHOVER_TIME);
return checkDate.getDate();
}
function getMonth (date) {