移除 setLocalHours
This commit is contained in:
@@ -2,7 +2,7 @@ import { FrontendOrBackendSession, pinus } from 'pinus';
|
||||
import { getGamedata } from '../pubUtils/gamedata';
|
||||
import EventRecord, { EventRecordModel } from '../db/EventRecord';
|
||||
import { RoleModel } from '../db/Role';
|
||||
import { genCode, decodeStrSingle, decodeStr, getRandomWithWeight, resResult, setLocalHours } from '../pubUtils/util';
|
||||
import { genCode, decodeStrSingle, decodeStr, getRandomWithWeight, resResult } from '../pubUtils/util';
|
||||
import { EVENT_STATUS, EVENT_RECORD_STATUS, EVENT_TYPE, EVENT_RANDOM_TYPE_ONE_OPEN, EVENT_QUIZ_NUM, EVENT_ANSWER_STATUS, FUNCS_ID } from '../consts';
|
||||
import { EVENT_REFRESH_NUM } from '../consts';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
@@ -61,8 +61,8 @@ export async function setBattleStatus(session: FrontendOrBackendSession, roleId:
|
||||
*/
|
||||
export function getEventTime(now: Date) {
|
||||
let curTime = Number(now);
|
||||
let todayA = setLocalHours(12, now); // 每天12点
|
||||
let todayB = setLocalHours(18, now); // 每天18点
|
||||
let todayA = now.setHours(12, 0, 0, 0); // 每天12点
|
||||
let todayB = now.setHours(18, 0, 0, 0); // 每天18点
|
||||
let yesterdayB = todayB - 86400000; // 前一天12点
|
||||
let t = 0;
|
||||
if(curTime < todayA) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import Role, { RoleModel, RoleType } from '../db/Role';
|
||||
import { PvpDefenseModel } from '../db/PvpDefense';
|
||||
|
||||
import { getWarJsons, getGamedata, getExpeditionById } from '../pubUtils/gamedata';
|
||||
import { decodeStr, resResult, setLocalHours, shouldRefresh } from '../pubUtils/util';
|
||||
import { decodeStr, resResult, shouldRefresh } from '../pubUtils/util';
|
||||
import { EXPEDITION_CONST, HERO_CE_RATIO, getAttrCeRatio } from '../consts';
|
||||
import { getAtrrNameById} from '../consts';
|
||||
import { ExpeditionWarRecordModel } from '../db/ExpeditionWarRecord';
|
||||
@@ -149,7 +149,7 @@ export async function getCEScaleAndRange(roleId: string, curDicExpedition: any)
|
||||
// 匹配,判断是不是新手期
|
||||
const role = await RoleModel.findByRoleId(roleId);
|
||||
let now = new Date();
|
||||
let today = setLocalHours(0, now);
|
||||
let today = now.setHours(0, 0, 0, 0);;
|
||||
let isNew = today - role.createdAt.getTime() <= 3*24*60*60*1000;
|
||||
let scale = isNew?curDicExpedition.CEScaleNew:curDicExpedition.CEScale;
|
||||
let range = isNew?curDicExpedition.CERangeNew:curDicExpedition.CERange;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
|
||||
import { DAILY_CONST } from './../consts';
|
||||
import { setLocalHours } from './../pubUtils/util';
|
||||
|
||||
|
||||
/**
|
||||
@@ -30,7 +29,7 @@ export default class DailyRecord extends BaseModel {
|
||||
const dailyRecord: DailyRecordType = await DailyRecordModel.findOne({ roleId, type }).lean(lean);
|
||||
let {count = 0, refTime = 0, buyCount = 0} = dailyRecord||{};
|
||||
let now = new Date();
|
||||
let today = setLocalHours(DAILY_CONST.REFRESH_TIME, now);
|
||||
let today = now.setHours(DAILY_CONST.REFRESH_TIME, 0, 0, 0);
|
||||
|
||||
if(today > refTime) {
|
||||
refTime = today; count = 0; buyCount = 0;
|
||||
|
||||
@@ -214,7 +214,9 @@ export function deltaDays(preTime: Date, proTime: Date): number {
|
||||
export function shouldRefresh(preTime: Date, now: Date, hour: number, deltaDay = 1): boolean {
|
||||
if (!preTime) return true;
|
||||
let curTime = new Date(now.getTime());
|
||||
let refeshTime = setLocalHours(hour, curTime);
|
||||
let refreshTime = new Date(now.getTime());
|
||||
refreshTime.setHours(hour, 0, 0, 0);
|
||||
let refeshTime = refreshTime.getTime();
|
||||
|
||||
if (refeshTime - preTime.getTime() > (deltaDay >= 1 ? deltaDay - 1 : 0) * 24 * 60 * 60 * 1000 && curTime.getTime() >= refeshTime) {
|
||||
return true;
|
||||
@@ -241,7 +243,7 @@ export function getRefTime(now = new Date(), hour: number, day = 0) {
|
||||
curTime.setDate(curTime.getDate() - 1);
|
||||
}
|
||||
}
|
||||
let today = setLocalHours(hour, curTime);
|
||||
let today = curTime.setHours(hour, 0, 0, 0);;
|
||||
return new Date(today + day * 24 * 60 * 60 * 1000);
|
||||
}
|
||||
|
||||
@@ -376,15 +378,6 @@ export function calculateNum(ratio: { A: number, B: number }, params: { num: num
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function setLocalHours(hour: number, curTime = new Date()) {
|
||||
// curTime: 格林威治时间
|
||||
let offset = curTime.getTimezoneOffset(); // 格林威治时间和本地时间之间的时差(分)
|
||||
let localTime = new Date(curTime.getTime() + offset * 60 * 1000 + 8 * 60 * 60 * 1000); // 中国时间
|
||||
localTime.setUTCHours(hour, 0, 0, 0); // 中国的几点
|
||||
return localTime.getTime() - 8 * 60 * 60 * 1000; // 回到格林威治时间
|
||||
}
|
||||
|
||||
export function ratioReward(rewardStr: string, ratio: number): string {
|
||||
let rewards = decodeIdCntArrayStr(rewardStr, ratio);
|
||||
let res = '';
|
||||
|
||||
Reference in New Issue
Block a user