MCPcopy
hub / github.com/callumalpass/tasknotes / calculateTotalTimeSpent

Function calculateTotalTimeSpent

src/utils/timeTrackingUtils.ts:77–91  ·  view source on GitHub ↗
(timeEntries: TimeEntry[])

Source from the content-addressed store, hash-verified

75}
76
77export function calculateTotalTimeSpent(timeEntries: TimeEntry[]): number {
78 if (!timeEntries || timeEntries.length === 0) return 0;
79
80 return timeEntries.reduce((total, entry) => {
81 if (entry.endTime) {
82 const durationMs =
83 new Date(entry.endTime).getTime() - new Date(entry.startTime).getTime();
84 return total + Math.floor(durationMs / (1000 * 60));
85 } else {
86 // Active session
87 const elapsedMs = Date.now() - new Date(entry.startTime).getTime();
88 return total + Math.floor(elapsedMs / (1000 * 60));
89 }
90 }, 0);
91}
92
93export function computeActiveTimeSessions(
94 tasks: TaskInfo[],

Calls 1

nowMethod · 0.80

Tested by

no test coverage detected