Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ZogStriP committed Jan 7, 2025
1 parent 7e5f471 commit a2be51c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,26 @@
<title>watty.top</title>
<input id=file type=file accept=".zip" onchange="handleFiles(this.files)">
<script>
to48 = (t) => {
if (t === "00:00:00") return 47;
const [h, m] = t.split(":").map(Number);
return (h * 2 + m / 30) - 1 | 0;
}

parse = (csv) => {
let data = {};
let day;

let day, data = {};

csv.split("\n").forEach((line) => {
const [a, b] = line.split(";");
if (a?.includes("/")) {
const [d, m, y] = a.split("/");
day = `${y}-${m}-${d}`;
data[day] = [];
} else if (a?.includes(":")) {
data[day][to48(a)] = b / 2;
let [h, m] = a.split(":").map(Number);
if (m === 0 || m === 30) {
const p = h === 0 && m === 0 ? 47 : h * 2 + m / 30 - 1;
data[day][p] = b / 2;
}
}
});

console.log(data);
};
}

handleFiles = (files) => {
const reader = new FileReader();
Expand Down

0 comments on commit a2be51c

Please sign in to comment.