Skip to content

Function: getTimeFragmentSession()

function getTimeFragmentSession(timeFragmentInterval, originalSession):
| {
active_seconds: number;
created_at: string;
currency: | "USD"
| "EUR"
| "GBP"
| "CAD"
| "AUD"
| "JPY"
| "CHF"
| "CNY"
| "INR"
| "BRL"
| "VEF";
end_time: string;
hourly_payment: boolean;
id: string;
memo: string | null;
paid: boolean;
payout_id: string | null;
salary: number;
start_time: string;
time_fragments_interval: number | null;
user_id: string;
work_project_id: string;
}
| InsertWorkTimeEntry;

Defined in: shared/src/helper/workHelper/getTimeFragmentSession.ts:19

Rounds a session to align with the specified time interval boundaries.

Example: If a session runs from 17:17 to 17:36 and the interval is 10 minutes, it will create a single session covering the aligned block:

  • 17:10–17:40 (30 minutes total duration)

The resulting session has:

  • start_time = floored to the nearest interval
  • end_time = ceiled to the nearest interval (or extended by one interval if equal to start)
  • active_seconds = total seconds in that block
ParameterTypeDescription
timeFragmentIntervalnumberTime interval for rounding (5, 10, 15, 30, 60 minutes)
originalSession| { active_seconds: number; created_at: string; currency: | "USD" | "EUR" | "GBP" | "CAD" | "AUD" | "JPY" | "CHF" | "CNY" | "INR" | "BRL" | "VEF"; end_time: string; hourly_payment: boolean; id: string; memo: string | null; paid: boolean; payout_id: string | null; salary: number; start_time: string; time_fragments_interval: number | null; user_id: string; work_project_id: string; } | InsertWorkTimeEntryOriginal session data to copy properties from

| { active_seconds: number; created_at: string; currency: | "USD" | "EUR" | "GBP" | "CAD" | "AUD" | "JPY" | "CHF" | "CNY" | "INR" | "BRL" | "VEF"; end_time: string; hourly_payment: boolean; id: string; memo: string | null; paid: boolean; payout_id: string | null; salary: number; start_time: string; time_fragments_interval: number | null; user_id: string; work_project_id: string; } | InsertWorkTimeEntry

A single session object aligned to the interval