Skip to content

Commit

Permalink
timer improvements, sorry rishit
Browse files Browse the repository at this point in the history
  • Loading branch information
Highfire1 committed Sep 22, 2023
1 parent 1d410de commit c559a09
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions frontend/src/app/hacks/Timer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export class Timer extends Component<TimerProps, TimerState>
protected TimeDifference: number;

public Tick(): void
{
{
this.UpdateTimeStamp()

setInterval(()=> {
this.UpdateTimeStamp();
if(this.TimeDifference > 0)
Expand All @@ -46,8 +48,8 @@ export class Timer extends Component<TimerProps, TimerState>
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() {
Expand All @@ -57,15 +59,20 @@ export class Timer extends Component<TimerProps, TimerState>

render()
{
return <div className={"text-white text-7xl max-[850px]:text-3xl"}>
{this.state.CurrentTimeStamp.Days}d {this.state.CurrentTimeStamp.Hours}h {this.state.CurrentTimeStamp.Minutes}m {this.state.CurrentTimeStamp.Seconds}s
return <div className={"text-white text-7xl max-[850px]:text-3xl"} suppressHydrationWarning>
{this.state.CurrentTimeStamp.Days}d {this.state.CurrentTimeStamp.Hours}h {this.state.CurrentTimeStamp.Minutes}m {this.state.CurrentTimeStamp.Seconds}s
</div>
}

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;
}
}

0 comments on commit c559a09

Please sign in to comment.