Generic Commit; Most likely a fix or small feature

This commit is contained in:
Darius
2025-11-18 01:03:24 +01:00
parent 5afb0e243d
commit 32c21f82eb
7 changed files with 37 additions and 2 deletions

View File

@@ -23,3 +23,9 @@ export interface HomeAssistantDeskPositionResult {
asBoolean: boolean;
asText: () => string;
}
export type API_HA_DeskPosition = {
position: string;
isStanding: boolean;
standingTime: string;
};

View File

@@ -31,6 +31,18 @@ export class TimeSpan {
}
}
export function calculateSecondsBetween(
start: number,
end: number,
): { seconds: number; toReadable: (roundToMinutes?: boolean) => string } {
const seconds = Math.max(60, (end - start) / 1000);
return {
seconds,
toReadable: (roundToMinutes?: boolean) =>
secondsToReadable(seconds, roundToMinutes),
};
}
export function secondsToReadable(
secs: number,
roundToMinutes: boolean = false,