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

@@ -22,4 +22,9 @@ export interface HomeAssistantDeskPositionResult {
asBoolean: boolean; asBoolean: boolean;
asText: () => string; asText: () => string;
} }
export type API_HA_DeskPosition = {
position: string;
isStanding: boolean;
standingTime: string;
};
//# sourceMappingURL=homeassistant.d.ts.map //# sourceMappingURL=homeassistant.d.ts.map

View File

@@ -1 +1 @@
{"version":3,"file":"homeassistant.d.ts","sourceRoot":"","sources":["../src/homeassistant.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QACV,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,CAAC;CACH,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC9C,GAAG,EAAE,mBAAmB,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,MAAM,CAAC;CACtB"} {"version":3,"file":"homeassistant.d.ts","sourceRoot":"","sources":["../src/homeassistant.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QACV,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,CAAC;CACH,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC9C,GAAG,EAAE,mBAAmB,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC"}

View File

@@ -5,5 +5,9 @@ export declare class TimeSpan {
private parseTime; private parseTime;
contains(timestamp?: number): boolean; contains(timestamp?: number): boolean;
} }
export declare function calculateSecondsBetween(start: number, end: number): {
seconds: number;
toReadable: (roundToMinutes?: boolean) => string;
};
export declare function secondsToReadable(secs: number, roundToMinutes?: boolean): string; export declare function secondsToReadable(secs: number, roundToMinutes?: boolean): string;
//# sourceMappingURL=timehelper.d.ts.map //# sourceMappingURL=timehelper.d.ts.map

View File

@@ -1 +1 @@
{"version":3,"file":"timehelper.d.ts","sourceRoot":"","sources":["../src/timehelper.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,GAAG,CAAqC;gBAEpC,WAAW,EAAE,MAAM;IAM/B,OAAO,CAAC,SAAS;IAKjB,QAAQ,CAAC,SAAS,GAAE,MAAmB,GAAG,OAAO;CAgBlD;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC9B,MAAM,CAmBR"} {"version":3,"file":"timehelper.d.ts","sourceRoot":"","sources":["../src/timehelper.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,GAAG,CAAqC;gBAEpC,WAAW,EAAE,MAAM;IAM/B,OAAO,CAAC,SAAS;IAKjB,QAAQ,CAAC,SAAS,GAAE,MAAmB,GAAG,OAAO;CAgBlD;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,KAAK,MAAM,CAAA;CAAE,CAOvE;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC9B,MAAM,CAmBR"}

8
dist/timehelper.js vendored
View File

@@ -1,6 +1,7 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
exports.TimeSpan = void 0; exports.TimeSpan = void 0;
exports.calculateSecondsBetween = calculateSecondsBetween;
exports.secondsToReadable = secondsToReadable; exports.secondsToReadable = secondsToReadable;
class TimeSpan { class TimeSpan {
constructor(timeSpanStr) { constructor(timeSpanStr) {
@@ -28,6 +29,13 @@ class TimeSpan {
} }
} }
exports.TimeSpan = TimeSpan; exports.TimeSpan = TimeSpan;
function calculateSecondsBetween(start, end) {
const seconds = Math.max(60, (end - start) / 1000);
return {
seconds,
toReadable: (roundToMinutes) => secondsToReadable(seconds, roundToMinutes),
};
}
function secondsToReadable(secs, roundToMinutes = false) { function secondsToReadable(secs, roundToMinutes = false) {
const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs; const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs;
var days = Math.floor(totalSeconds / (3600 * 24)); var days = Math.floor(totalSeconds / (3600 * 24));

View File

@@ -23,3 +23,9 @@ export interface HomeAssistantDeskPositionResult {
asBoolean: boolean; asBoolean: boolean;
asText: () => string; 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( export function secondsToReadable(
secs: number, secs: number,
roundToMinutes: boolean = false, roundToMinutes: boolean = false,