Skip to main content

Module calculator

Module calculator 

Source
Expand description

Core shift calculation functions.

All functions are pure: given the same inputs, always produce the same outputs. No platform dependencies, no I/O, no state.

§The algorithm

date → calculate_day_offset(date, reference_date)
     → normalize_cycle_index(offset, cycle_length)
     → cycle[index]  →  ShiftType

Team phase offset is added to the day offset before normalization:

offset = (date - reference_date) + team_phase_offset

Functions§

calculate_day_offset
Number of days between date and reference_date.
get_shift_info
Get full shift info (date, day of cycle, cycle index, shift type) in one call.
get_shift_type_for_date
Get the shift type for a given date.
normalize_cycle_index
Normalize any offset into the range 0..cycle_length.
team_phase_offset_for
Team phase offset in days.