diff --git a/Web App/web/src/components/TimeField.vue b/Web App/web/src/components/TimeField.vue
new file mode 100644
index 0000000..3a70f69
--- /dev/null
+++ b/Web App/web/src/components/TimeField.vue
@@ -0,0 +1,147 @@
+
+
+
+
+
+
+
+
diff --git a/Web App/web/src/lib/format.js b/Web App/web/src/lib/format.js
index 4fafc0b..3a38a78 100644
--- a/Web App/web/src/lib/format.js
+++ b/Web App/web/src/lib/format.js
@@ -109,13 +109,25 @@ export function formatTime(value) {
const pad = (n) => String(n).padStart(2, "0");
const mm = pad(d.getMinutes());
- const mode = prefs.timeFormat;
- const twelve = mode === "12" || (mode !== "24" && regionReadsTwelveHour());
- if (!twelve) return `${pad(h)}:${mm}`;
+ if (!clockIsTwelveHour()) return `${pad(h)}:${mm}`;
// 12 for both noon and midnight, and midnight is the am one.
return `${pad(h % 12 || 12)}:${mm} ${h < 12 ? "am" : "pm"}`;
}
+// Whether times are written on a 12-hour clock right now: what the setting says
+// outright, or what the region says when it is left on auto.
+//
+// Exported because printing a time is not the only thing that has to know. A
+// control that lets somebody *enter* one has to offer the same clock, and a box
+// that reads 13:45 beside a picker that says 01:45 PM is the disagreement this
+// setting exists to end (see components/TimeField.vue).
+export function clockIsTwelveHour() {
+ const mode = prefs.timeFormat;
+ if (mode === "12") return true;
+ if (mode === "24") return false;
+ return regionReadsTwelveHour();
+}
+
// Whether the chosen region tells the time on a 12-hour clock — the one question
// "auto" asks it. Cached because this is asked once per timestamp on a page that
// can hold a great many, and the answer only changes when the region does.
diff --git a/Web App/web/src/views/Charging.vue b/Web App/web/src/views/Charging.vue
index 46d7e5f..fe4baeb 100644
--- a/Web App/web/src/views/Charging.vue
+++ b/Web App/web/src/views/Charging.vue
@@ -5,6 +5,7 @@ import { prefs } from "../prefs";
import { askConfirm } from "../lib/confirm.js";
import { api } from "../api";
import { formatDateTime } from "../lib/format.js";
+import TimeField from "../components/TimeField.vue";
import { CHARGING_TABS, defaultTabFor } from "../lib/tabs.js";
import ChargerImportModal from "../components/ChargerImportModal.vue";
@@ -2592,18 +2593,13 @@ onMounted(async () => {
-
–
-