Skip to content

Commit 3096c21

Browse files
committed
dates, sorting
1 parent 7ee95e6 commit 3096c21

6 files changed

Lines changed: 16 additions & 8 deletions

File tree

data/games.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
[
22
{
3-
"timestamp": "09.09.2025 13:38",
3+
"timestamp": "2025-09-09T13:38:00",
44
"white": "2",
55
"black": "1",
66
"result": "1-0",
77
"pgn": "[Date \"2025.09.09\"]\n[White \"Ramon\"]\n[Black \"Hans\"]\n[Result \"*\"]\n[Time \"13:38:26\"]\n\n1. e4 e5 2. Nf3 Nf6 3. Nxe5 Nxe4 4. Qe2 Nxf2 5. Nc6+ Qe7 6. Nxe7 Bxe7 7. Qxf2 Bh4 8. g3 *"
88
},
99
{
10-
"timestamp": "09.09.2025 13:45",
10+
"timestamp": "2025-09-09T13:45:00",
1111
"white": "2",
1212
"black": "1",
1313
"result": "1-0",
1414
"pgn": "[Date \"2025.09.09\"]\n[White \"Ramon\"]\n[Black \"Hans\"]\n[Result \"1/2-1/2\"]\n[Time \"13:45:04\"]\n\n1. e4 e5 2. Nf3 Nf6 3. Nxe5 Nxe4 4. Qe2 d5 5. d3 Bd6 6. Ng4 Bb4+ 7. Bd2 Bxg4 8. Qxg4 Bxd2+ 9. Nxd2 Qg5 10. Qc8+ Qd8 11. Qg4 O-O 12. O-O-O f5 13. Qe2 Nxd2 14. Qxd2 Re8 15. d4 Nc6 16. Bb5 a6 17. Bxc6 bxc6 18. Rhe1 h6 19. Rxe8+ Qxe8 20. Qf4 Qf7 21. h3 g5 22. Qe5 Re8 23. Qg3 Re4 24. c3 g4 25. f3 Re3 26. hxg4 Qg7 27. Qf2 Re6 28. gxf5 Rf6 29. g4 h5 30. gxh5 Rxf5 31. Rg1 Rg5 32. Rxg5 Qxg5+ 33. Kc2 Qf5+ 34. Kb3 Qxh5 35. f4 Qd1+ 36. Ka3 Qg4 37. f5 c5 38. dxc5 d4 39. Qxd4 Qxf5 40. Qd8+ Qf8 41. Qxc7 a5 42. Qg3+ Qg7 43. Qb8+ Qf8 44. Qxf8+ Kxf8 45. Ka4 Kg7 46. Kxa5 Kf7 47. Kb6 Ke7 48. Kb7 Kd7 49. c6+ Kd8 50. c7+ Kd7 51. c8=Q+ Ke7 52. Qc7+ Ke6 53. a4 Kd5 54. a5 Ke4 55. a6 Kd3 56. a7 Kc2 57. a8=Q Kxb2 58. Qa7 Kb3 59. Qab6+ Ka4 60. Qcc5 1/2-1/2"
1515
},
1616
{
17-
"timestamp": "09.09.2025 15:55",
17+
"timestamp": "2025-09-09T15:55:00",
1818
"white": "3",
1919
"black": "5",
2020
"result": "1-0",

data/moments.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[
22
{
3-
"timestamp": "05.09.2025 15:42",
3+
"timestamp": "2025-09-05T15:42:00",
44
"pgn": "1. a4 c5 2. Ra3 Qb6 3. Rb3 Qe6 4. d4 Qd6 5. Nh3 g6 6. Bf4 e5 7. Bxe5 Qd5 8. Bxh8 c4 9. Nf4 Qa5+ 10. Nc3 cxb3 11. Nd5 Na6 12. e4 bxc2 13. Qxc2 Nb4 14. Nxb4 Bxb4 15. d5 b6 16. Be2 Ba6 17. Bf3 Rc8 18. e5 Bxc3+ 19. bxc3 Rxc3 20. Kd2 Rxc2+ 21. Kxc2 Qc5+ 22. Kb3 Qc4+ 23. Ka3 Qc5+ 24. Ka2 Bc4+ 25. Kb2 Qb4+ 26. Kc2 Qb3+ 27. Kd2 Qd3+ 28. Ke1 Qc3+ 29. Kd1 Bb3+ 30. Ke2 Qc2+ 31. Ke3 Qc5+ 32. Kf4 Qc4+ 33. Kg3 f6 34. exf6 Qc7+ 35. Kh3 Bc2 36. Re1+ Ne7 37. Be4 Qc3+ 38. Re3 Qd2 39. Bxc2 Qxc2 40. Rxe7+ Kd8 41. Rxh7 Qd3+ 42. Kg4 Qe4+ 43. Kg5 Qf5+ 44. Kh6 Qh5+ 45. K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qc4+ 23. Ka3 Qc5+ 24. Ka2 Bc4+ 25. Kb2 Qb4+ 26. Kc2 Qb3+ 27. Kd2 Qd3+ 28. Ke1 Qc3+ 29. Kd1 Bb3+ 30. Ke2"
1313
}
1414
]

scoreboard/src/components/games.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
2+
import { formatTimestamp } from '../scripts/utilities.ts';
3+
24
const { games, players } = Astro.props;
35
46
function getResult(pgnResult: string, player: string)
@@ -28,7 +30,7 @@ function getResult(pgnResult: string, player: string)
2830
games.map((g, i) => (
2931
<tr>
3032
<td>
31-
{g.timestamp}
33+
{formatTimestamp(g.timestamp)}
3234
</td>
3335
<td>
3436
<div class="player"><span class={`dot white`}></span>{players[g.white]}</div>

scoreboard/src/components/moments.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import { formatTimestamp } from '../scripts/utilities.ts';
23
const { moments } = Astro.props;
34
---
45

@@ -17,7 +18,7 @@ const { moments } = Astro.props;
1718
moments.map((g, i) => (
1819
<tr>
1920
<td>
20-
{g.timestamp}
21+
{formatTimestamp(g.timestamp)}
2122
</td>
2223
<td align="center">
2324
<button

scoreboard/src/pages/index.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const games: Array<{
1818
result: string;
1919
pgn: string;
2020
}> = GameData;
21+
games.sort((a, b) => b.timestamp.localeCompare(a.timestamp));
2122
2223
const moments: Array<{
2324
timestamp: string;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export function formatTimestamp(ts: string) {
2+
const date = new Date(ts);
3+
return date.toLocaleString('cs-CZ', { hour: '2-digit', minute: '2-digit', year: 'numeric', month: '2-digit', day: '2-digit' });
4+
}

0 commit comments

Comments
 (0)