Added a Workarond for the DST (European Daylight Saving Time (DST))
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Database } from "bun:sqlite";
|
||||
import { TEventType, type TEvent } from "./event.types";
|
||||
import { getTsNow, pad_l2, transformArray } from "../../util";
|
||||
import { getTsNow, pad_l2, transformArray, formatTimeDiff, isEuropeanDST, subtractHours } from "../../util";
|
||||
|
||||
const BASE_URL = "https://77th-jsoc.com/service.php?action=get_events";
|
||||
|
||||
@@ -195,10 +195,13 @@ export class Event implements TEventEntity {
|
||||
return `${title_prefix_arr.length >= 1 ? ( title_prefix_arr.join(" " ) + " - ") : "" }${this.title} (${ TEventType[ this.event_type ] })`;
|
||||
}
|
||||
get_body() {
|
||||
const BaseTime = new Date(`${this.date_at} 21:00`);
|
||||
const RelativeEventTime = new Date(`${this.date_at} ${this.get_time_start()}`);
|
||||
const TimeDiff = formatTimeDiff( BaseTime, RelativeEventTime);
|
||||
const body = [
|
||||
`Title: ${this.title}`,
|
||||
`Date: ${this.date_at}`,
|
||||
`Time: ${this.time_start}`,
|
||||
`Time: ${this.get_time_start()}${ TimeDiff ? ` (Optime ${TimeDiff})` : "" }`,
|
||||
`Type: ${ TEventType[ this.event_type ] }`,
|
||||
`Location: ${this.location}`,
|
||||
`By: ${this.posted_by}`,
|
||||
@@ -219,4 +222,15 @@ export class Event implements TEventEntity {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
get_time_start () {
|
||||
const date = new Date( `${this.date_at} ${this.time_start}` );
|
||||
if ( ! isEuropeanDST( date ) ) {
|
||||
const newDate = subtractHours( date, 1);
|
||||
const hours = newDate.getHours();
|
||||
const minutes = newDate.getMinutes();
|
||||
return `${pad_l2(hours)}:${pad_l2(minutes)}`;
|
||||
}
|
||||
return this.time_start;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user