-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7766ec
commit dee1929
Showing
5 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {Timer} from "@/app/hacks/Timer"; | ||
|
||
export function Body() | ||
{ | ||
return <div className={"bg-hacks-bg-black"}> | ||
<Timer EndTime={new Date(2023, 8, 23, 8, 0, 0)}/> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
"use client"; | ||
|
||
import {Component, useState} from "react"; | ||
|
||
class TimeStamp | ||
{ | ||
public readonly Days: number; | ||
public readonly Hours: number; | ||
public readonly Minutes: number; | ||
public readonly Seconds: number; | ||
|
||
public constructor(days: number, hours: number, minutes: number, seconds: number) | ||
{ | ||
this.Days = days; | ||
this.Hours = hours; | ||
this.Seconds = seconds; | ||
this.Minutes = minutes; | ||
} | ||
} | ||
|
||
interface TimerProps | ||
{ | ||
EndTime: Date; | ||
} | ||
|
||
interface TimerState | ||
{ | ||
CurrentTimeStamp: TimeStamp; | ||
} | ||
|
||
export class Timer extends Component<TimerProps, TimerState> | ||
{ | ||
protected TimeDifference: number; | ||
|
||
protected Days: number; | ||
|
||
public Tick(): void | ||
{ | ||
setInterval(()=> { | ||
this.UpdateTimeStamp(); | ||
if(this.TimeDifference > 0) | ||
this.TimeDifference -= 1; | ||
}, 1000); | ||
} | ||
|
||
public UpdateTimeStamp(): void { | ||
let seconds: number = Math.floor(this.TimeDifference % 60), | ||
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)}); | ||
} | ||
|
||
public componentWillMount() { | ||
this.TimeDifference = Math.abs(this.props.EndTime - new Date()) / 1000; | ||
this.setState({CurrentTime: this.TimeDifference, CurrentTimeStamp: new TimeStamp(0,0,0,0)}); | ||
this.Tick(); | ||
} | ||
|
||
render() | ||
{ | ||
return <div className={"text-white text-3xl"}> | ||
{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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import {Header} from "./Header"; | ||
import {Body} from "@/app/hacks/Body"; | ||
|
||
export default function Page() | ||
{ | ||
return <div className={"grid grid-rows-[30vh_70vh] bg-navs-bg-black h-full font-audiowide"}> | ||
<Header/> | ||
<Body/> | ||
</div>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters