boyonthebeach2k / archimedes-fgo

F/GO damage, refund & stars calculator for enemies and servants, as well as other utility functions
2 stars 3 forks source link

Reset Times doesn't work properly when dst switches across the globe. #5

Open enshael opened 3 weeks ago

enshael commented 3 weeks ago

Someone fill in the en server hours

npm install @js-joda/core

import { LocalDateTime, ZoneOffset } = from "@js-joda/core";

let now = LocalDateTime.now(ZoneOffset.UTC);
let fpReset = LocalDateTime.of(now.year(), now.monthValue(), now.dayOfMonth());
let loginReset = LocalDateTime.of(now.year(), now.monthValue(), now.dayOfMonth());
let maintStart = LocalDateTime.of(now.year(), now.monthValue(), now.dayOfMonth());
let maintEnd = LocalDateTime.of(now.year(), now.monthValue(), now.dayOfMonth());
let description = '';

if (region === "JP") {
  fpReset= fpReset.withHour(15); // 00:00 JST
  loginReset = loginReset.withHour(19); // 04:00 JST
  maintStart = maintStart.withHour(4); // 13:00 JST
  maintEnd = maintEnd.withHour(9); // 18:00 JST

  description =
    `FP/Daily Quest/Command Seal: <t:${fpReset.toInstant(ZoneOffset.UTC).epochSecond()}:t>\n` +
    `Login Rewards: <t:${loginReset.toInstant(ZoneOffset.UTC).epochSecond()}:t>\n` +
    `Maintenance Start: <t:${maintStart.toInstant(ZoneOffset.UTC).epochSecond()}:t>\n` +
    `Maintenance End/Banner Change: <t:${maintEnd.toInstant(ZoneOffset.UTC).epochSecond()}:t>`;
} else {
  fpReset= fpReset.withHour(); // 
  loginReset = loginReset.withHour(); // 
  maintStart = maintStart.withHour(); // 
  maintEnd = maintEnd.withHour(); // 

  description =
    `FP/Daily Quest/Command Seal: <t:${fpReset.toInstant(ZoneOffset.UTC).epochSecond()}:t>\n` +
    `Login Rewards/Maintenance Start/Banner Change: <t:${loginReset.toInstant(ZoneOffset.UTC).epochSecond()}:t>\n` +
    `Maintenance End: <t:${maintEnd.toInstant(ZoneOffset.UTC).epochSecond()}:t>`;
}