Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

502 B
Raw Blame
export type TimedEntry = {
  readonly startTime: string;
  readonly endTime: string | null;
  readonly duration: number | null;
};

export function entrySeconds(entry: TimedEntry, now: Date): number {
  if (entry.duration !== null) return entry.duration;
  const start = Date.parse(entry.startTime);
  const end =
    entry.endTime === null ? now.getTime() : Date.parse(entry.endTime);
  if (Number.isNaN(start) || Number.isNaN(end)) return 0;
  return Math.max(0, Math.floor((end - start) / 1000));
}