Thanks asonix.
This commit is contained in:
parent
e820382c28
commit
ae7876cf91
@ -2,18 +2,17 @@ import BasicPage from "../../components/basic-page-template";
|
||||
import WCard from "../../components/werefox-card";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
function getTimes(interval) {
|
||||
let expected = Date.now() - new Date("December 11, 2020 00:00:00") + interval;
|
||||
let days = Math.round(expected / 1000 / 60 / 60 / 24);
|
||||
let hours = (new Date(expected).getHours() + 6) % 24;
|
||||
let minutes = new Date(expected).getMinutes();
|
||||
let seconds = new Date(expected).getSeconds();
|
||||
function getTimes() {
|
||||
let total_ms = Date.now() - new Date("December 11, 2020 00:00:00");
|
||||
let days = Math.round(total_ms / 1000 / 60 / 60 / 24);
|
||||
let hours = (new Date(total_ms).getHours() + 6) % 24;
|
||||
let minutes = new Date(total_ms).getMinutes();
|
||||
let seconds = new Date(total_ms).getSeconds();
|
||||
return {
|
||||
expected: expected,
|
||||
days: days,
|
||||
hours: hours,
|
||||
minutes: minutes,
|
||||
seconds: seconds,
|
||||
days: `${days} days,`,
|
||||
hours: `${hours} hours,`,
|
||||
minutes: `${minutes} minutes,`,
|
||||
seconds: `and ${seconds}.`,
|
||||
};
|
||||
}
|
||||
|
||||
@ -22,18 +21,11 @@ export default function HRT() {
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
setTimesArray(getTimes(0), 1000);
|
||||
setTimesArray(getTimes(), 1000);
|
||||
});
|
||||
return () => clearInterval(interval);
|
||||
}, [getTimes, setTimesArray]);
|
||||
|
||||
const initialTimesArray = [
|
||||
`${timesArray["days"]} days, `,
|
||||
`${timesArray["hours"]} hours, `,
|
||||
`${timesArray["minutes"]} minutes, `,
|
||||
`and ${timesArray["seconds"]} seconds`,
|
||||
];
|
||||
|
||||
return (
|
||||
<BasicPage
|
||||
page_title="Alexis Werefox HRT Tracker"
|
||||
@ -46,8 +38,8 @@ export default function HRT() {
|
||||
I have been on HRT for:
|
||||
<br />
|
||||
<p className="grid grid-cols-1 grid-rows-4">
|
||||
{initialTimesArray.map((t, n) => (
|
||||
<p id={`time_${n}`}>{t}</p>
|
||||
{Object.keys(timesArray).map(t => (
|
||||
<p>{timesArray[t]}</p>
|
||||
))}
|
||||
</p>
|
||||
</p>
|
||||
|
Loading…
Reference in New Issue
Block a user