Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions web/js/Chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function formatBytes(bytes) {
const formatters = {
toLocaleDate: (el) => (value, _) => {
const date = new Date(value);
return date.toLocaleDateString(locale(), {
return date.toLocaleDateString(navigator.language, {
day: "numeric",
month: "short",
});
Expand All @@ -82,10 +82,7 @@ const tooltipFormatters = {
formatHours: (value) => formatHours(value, { includeMinutes: true }),
};

function locale() {
const region = (navigator.language || navigator.userLanguage).split("-")[1];
return `en-${region}`;
}


export default {
mounted() {
Expand Down Expand Up @@ -343,23 +340,23 @@ function tooltipFormatter(options = {}) {
if (!Number.isNaN(Date.parse(title))) {
const date = new Date(title);
if (options.dateFormat == "minute") {
title = date.toLocaleDateString(locale(), {
title = date.toLocaleDateString(navigator.language, {
day: "numeric",
month: "short",
year: "numeric",
hour: "numeric",
minute: "numeric",
});
} else if (options.dateFormat == "hour") {
const dateStr = date.toLocaleDateString(locale(), {
const dateStr = date.toLocaleDateString(navigator.language, {
day: "numeric",
month: "short",
year: "numeric",
});
const hour = String(date.getHours()).padStart(2, "0");
title = `${dateStr}, ${hour}:00`;
} else {
title = date.toLocaleDateString(locale(), {
title = date.toLocaleDateString(navigator.language, {
day: "numeric",
month: "short",
year: "numeric",
Expand Down
Loading