updated api calls with copyright and routes
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// 404.js
|
||||
|
||||
import Image from "next/image";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
const FourOhFour = (props) => {
|
||||
const router = useRouter();
|
||||
|
||||
let numbWeeks = router.query.weekstoday;
|
||||
|
||||
function addThousandsSeparator(e) {
|
||||
return e.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
|
||||
}
|
||||
|
||||
function countDownToChristmas() {
|
||||
var $now = new Date();
|
||||
var $yearCount = $now.getFullYear();
|
||||
|
||||
if ($now.getMonth() + 1 == 12 && $now.getDate() >= 25) {
|
||||
$yearCount = $yearCount + 1;
|
||||
}
|
||||
|
||||
var $xmas = new Date($yearCount, 11, 25);
|
||||
var $now_seconds = Math.round($now.getTime() / 1e3);
|
||||
var $xmas_seconds = Math.round($xmas.getTime() / 1e3);
|
||||
var $seconds_to_go = $xmas_seconds - $now_seconds;
|
||||
var $minutes_to_go = Math.round($seconds_to_go / 60);
|
||||
var $hours_to_go = ($minutes_to_go / 60).toFixed(1);
|
||||
var $days_to_go = ($hours_to_go / 24 - 1).toFixed();
|
||||
var $sleeps_to_go = parseInt($days_to_go) + 1;
|
||||
var $weeks_to_go = ($minutes_to_go / 60 / 24 / 7).toFixed(2);
|
||||
var $fortnights_to_go = ($minutes_to_go / 60 / 24 / 7 / 2).toFixed(2);
|
||||
var $months_to_go = ($weeks_to_go / (52 / 12)).toFixed(2);
|
||||
var $years_to_go = ($weeks_to_go / 52).toFixed(2);
|
||||
|
||||
return $days_to_go;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Image
|
||||
src={"/api/days/" + countDownToChristmas()}
|
||||
width="940"
|
||||
height="788"
|
||||
alt="weeks"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FourOhFour;
|
||||
Reference in New Issue
Block a user