add time to chron
This commit is contained in:
@@ -18,6 +18,11 @@ export function createTimestamp(): string {
|
|||||||
return new Date().toISOString();
|
return new Date().toISOString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formatTime(date: Date): string {
|
||||||
|
const time = [date.getHours(), date.getMinutes()];
|
||||||
|
return time.join(":");
|
||||||
|
}
|
||||||
|
|
||||||
// filters
|
// filters
|
||||||
export type StringEntryObject = { [key: string]: Stringifiable | undefined };
|
export type StringEntryObject = { [key: string]: Stringifiable | undefined };
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -1,7 +1,7 @@
|
|||||||
import { v4 } from "uuid";
|
import { v4 } from "uuid";
|
||||||
import * as React from "../../react";
|
import * as React from "../../react";
|
||||||
import { allTranslations, Translations } from "../../View/translations";
|
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 StorageModel from "../../Model/Global/storageModel";
|
||||||
import SettingsModel from "../../Model/Global/settingsModel";
|
import SettingsModel from "../../Model/Global/settingsModel";
|
||||||
import FileTransferModel from "../../Model/Global/fileTransferModel";
|
import FileTransferModel from "../../Model/Global/fileTransferModel";
|
||||||
@@ -73,9 +73,13 @@ export default class CoreViewModel {
|
|||||||
// CHRON
|
// CHRON
|
||||||
chronHandlerManager = new HandlerManager<void>();
|
chronHandlerManager = new HandlerManager<void>();
|
||||||
todayDate = new React.State<Date>(new Date());
|
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);
|
return new Date(this.todayDate.value);
|
||||||
}
|
}
|
||||||
|
get timeString(): string {
|
||||||
|
return this.time.value.join(":");
|
||||||
|
}
|
||||||
|
|
||||||
startChron = (): void => {
|
startChron = (): void => {
|
||||||
setInterval(this.chronHandlerManager.trigger, 2000);
|
setInterval(this.chronHandlerManager.trigger, 2000);
|
||||||
@@ -83,9 +87,10 @@ export default class CoreViewModel {
|
|||||||
|
|
||||||
handleChron = (): void => {
|
handleChron = (): void => {
|
||||||
const newDate = new Date();
|
const newDate = new Date();
|
||||||
if (this.unwrappedTodayDate.toDateString() == newDate.toDateString())
|
if (this.unwrappedTodayDate.toDateString() != newDate.toDateString())
|
||||||
return;
|
|
||||||
this.todayDate.value = new Date();
|
this.todayDate.value = new Date();
|
||||||
|
if (formatTime(newDate) != this.timeString)
|
||||||
|
this.time.value = [newDate.getHours(), newDate.getMinutes()];
|
||||||
};
|
};
|
||||||
|
|
||||||
// DRAG & DROP
|
// DRAG & DROP
|
||||||
|
|||||||
Reference in New Issue
Block a user