Skip to content

Commit fe1b90e

Browse files
authored
Merge pull request #686 from gnmyt/fixes/timezone
🕒 Zeitzonen-Problem behoben
2 parents dac6036 + bdd30a7 commit fe1b90e

File tree

4 files changed

+25
-8
lines changed

4 files changed

+25
-8
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ RUN mv /myspeed/client/build /myspeed
1414

1515
FROM node:18-alpine
1616

17+
RUN apk add --no-cache tzdata
18+
1719
ENV NODE_ENV=production
20+
ENV TZ=Etc/UTC
1821

1922
WORKDIR /myspeed
2023

client/src/pages/Statistics/charts/PingChart.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ const chartOptions = {
1818
};
1919

2020
const SpeedChart = (props) => {
21+
const testTime = localStorage.getItem("testTime") || 1;
2122
const chartData = {
22-
labels: props.labels,
23+
labels: testTime < 3 ? props.labels.map((label) => new Date(label).toLocaleTimeString([],
24+
{hour: "2-digit", minute: "2-digit"})) : props.labels.slice(1).map((label) =>
25+
new Date(label).toLocaleDateString()),
2326
datasets: [
2427
{
2528
label: t("latest.ping"),
26-
data: props.data.ping,
29+
data: testTime < 3 ? props.data.ping : props.data.ping.slice(1),
2730
borderColor: '#45C65A',
2831
},
2932
],

client/src/pages/Statistics/charts/SpeedChart.jsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,22 @@ const chartOptions = {
1717
};
1818

1919
const SpeedChart = (props) => {
20+
const testTime = localStorage.getItem("testTime") || 1;
2021
const chartData = {
21-
labels: props.labels,
22+
labels: testTime < 3 ? props.labels.map((label) => new Date(label).toLocaleTimeString([],
23+
{hour: "2-digit", minute: "2-digit"})) : props.labels.slice(1).map((label) =>
24+
new Date(label).toLocaleDateString()),
2225
datasets: [
23-
{label: t("latest.down"), data: props.data.download, borderColor: '#45C65A'},
24-
{label: t("latest.up"), data: props.data.upload, borderColor: '#456AC6'},
26+
{
27+
label: t("latest.down"),
28+
data: testTime < 3 ? props.data.download : props.data.download.slice(1),
29+
borderColor: '#45C65A'
30+
},
31+
{
32+
label: t("latest.up"),
33+
data: testTime < 3 ? props.data.upload : props.data.upload.slice(1),
34+
borderColor: '#456AC6'
35+
},
2536
],
2637
};
2738

server/controller/speedtests.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ module.exports.listAverage = async (days) => {
7171
time: Math.round(avgNumbers["time"]),
7272
type: "average",
7373
amount: currentDay.length,
74-
created: created.getFullYear() + "-" + (created.getMonth() + 1) + "-" + created.getDate()
74+
created: created.toISOString()
7575
});
7676
}
7777

@@ -124,8 +124,8 @@ module.exports.listStatistics = async (days) => {
124124
upload: mapFixed(notFailed, "upload"),
125125
time: mapRounded(notFailed, "time"),
126126
data,
127-
labels: days >= 3 ? avgEntries.map((entry) => new Date(entry.created).toLocaleDateString())
128-
: notFailed.map((entry) => new Date(entry.created).toLocaleTimeString([], {hour: "2-digit", minute: "2-digit"}))
127+
labels: days >= 3 ? avgEntries.map((entry) => new Date(entry.created).toISOString())
128+
: notFailed.map((entry) => new Date(entry.created).toISOString())
129129
};
130130
}
131131

0 commit comments

Comments
 (0)