add time to chron

This commit is contained in:
marlon-erler
2026-09-25 19:05:36 +02:00
parent 78f8ff9943
commit 58d64858db
3 changed files with 75 additions and 65 deletions
+5
View File
@@ -18,6 +18,11 @@ export function createTimestamp(): string {
return new Date().toISOString();
}
export function formatTime(date: Date): string {
const time = [date.getHours(), date.getMinutes()];
return time.join(":");
}
// filters
export type StringEntryObject = { [key: string]: Stringifiable | undefined };
Binary file not shown.
+9 -4
View File
@@ -1,7 +1,7 @@
import { v4 } from "uuid";
import * as React from "../../react";
import { allTranslations, Translations } from "../../View/translations";
import { HandlerManager } from "../../Model/Utility/utility";
import { formatTime, HandlerManager } from "../../Model/Utility/utility";
import StorageModel from "../../Model/Global/storageModel";
import SettingsModel from "../../Model/Global/settingsModel";
import FileTransferModel from "../../Model/Global/fileTransferModel";
@@ -73,9 +73,13 @@ export default class CoreViewModel {
// CHRON
chronHandlerManager = new HandlerManager<void>();
todayDate = new React.State<Date>(new Date());
get unwrappedTodayDate() {
time = new React.State<[number, number]>([0, 0]);
get unwrappedTodayDate(): Date {
return new Date(this.todayDate.value);
}
get timeString(): string {
return this.time.value.join(":");
}
startChron = (): void => {
setInterval(this.chronHandlerManager.trigger, 2000);
@@ -83,9 +87,10 @@ export default class CoreViewModel {
handleChron = (): void => {
const newDate = new Date();
if (this.unwrappedTodayDate.toDateString() == newDate.toDateString())
return;
if (this.unwrappedTodayDate.toDateString() != newDate.toDateString())
this.todayDate.value = new Date();
if (formatTime(newDate) != this.timeString)
this.time.value = [newDate.getHours(), newDate.getMinutes()];
};
// DRAG & DROP