From c559a099347f7aa63d81df88d52ca80a583c1b90 Mon Sep 17 00:00:00 2001 From: Anderson T Date: Fri, 22 Sep 2023 00:17:43 -0700 Subject: [PATCH] timer improvements, sorry rishit --- frontend/src/app/hacks/Timer.tsx | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/hacks/Timer.tsx b/frontend/src/app/hacks/Timer.tsx index a5f7345..961ec08 100644 --- a/frontend/src/app/hacks/Timer.tsx +++ b/frontend/src/app/hacks/Timer.tsx @@ -33,7 +33,9 @@ export class Timer extends Component protected TimeDifference: number; public Tick(): void - { + { + this.UpdateTimeStamp() + setInterval(()=> { this.UpdateTimeStamp(); if(this.TimeDifference > 0) @@ -46,8 +48,8 @@ export class Timer extends Component minutes: number = Math.floor((this.TimeDifference % 3600) / 60), hours: number = Math.floor((this.TimeDifference % 86400) / 3600), days: number = Math.floor(this.TimeDifference / (3600 * 24)); - - this.setState({CurrentTimeStamp: new TimeStamp(days, hours, minutes, seconds)}); + + this.setState({CurrentTimeStamp: new TimeStamp(days, hours, minutes, seconds)} ); } public UNSAFE_componentWillMount() { @@ -57,15 +59,20 @@ export class Timer extends Component render() { - return
- {this.state.CurrentTimeStamp.Days}d {this.state.CurrentTimeStamp.Hours}h {this.state.CurrentTimeStamp.Minutes}m {this.state.CurrentTimeStamp.Seconds}s + return
+ {this.state.CurrentTimeStamp.Days}d {this.state.CurrentTimeStamp.Hours}h {this.state.CurrentTimeStamp.Minutes}m {this.state.CurrentTimeStamp.Seconds}s
} constructor(props: TimerProps) { super(props); + + // I can't figure out how to fix the server time right now, SORRY RISHIT + let date = new Date(); + date.setHours(date.getHours()-7); - this.TimeDifference = Math.abs((this.props.EndTime.valueOf() - new Date().valueOf())) / 1000; + this.TimeDifference = Math.abs((this.props.EndTime.valueOf() - date.valueOf())) / 1000; + //this.TimeDifference = Math.abs((this.props.EndTime.valueOf() - new Date().valueOf())) / 1000; } } \ No newline at end of file