Skip to content

Commit

Permalink
Circulation - Fix excess leading zeroes in AED-X and CPR time formatt…
Browse files Browse the repository at this point in the history
…ing (#681)

**When merged this pull request will:**
- Overhaul the way AED-X and CPR timestamps are formatted, fixing stuff
like this:

![malformed-time-01](https://github.com/user-attachments/assets/96d32023-1ef2-4388-83d2-18106f762aae)

![malformed-time-02](https://github.com/user-attachments/assets/ab89d90a-0e11-4693-b294-c4b66f115c24)
  • Loading branch information
mrschick authored Jan 3, 2025
1 parent f875424 commit 18a1652
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
13 changes: 11 additions & 2 deletions addons/circulation/functions/fnc_AEDX_ViewMonitor.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,17 @@ GVAR(PulseRateReady) = true;

// Handle date and time display - [year,month,day,hour,min]

ctrlSetText [IDC_DISPLAY_DATEANDTIME, format ["%1/%2/%3 %4:%5", (["", "0"] select (date select 2 < 10)) + str (date select 2), (["", "0"] select (date select 1 < 10)) + str (date select 1), date select 0, (["", "0"] select (date select 3 < 10)) + str (date select 3), (["", "0"] select (date select 4 < 10)) + str (date select 4)]];
ctrlSetText [IDC_DISPLAY_ELAPSEDTIME, format ["%1:%2:%3", (["", "0"] select (floor time / 3600 < 10)) + str (floor(time/3600)), (["", "0"] select (floor time / 3600 - floor time / 3600 * 60 < 10)) + str (floor(((time/3600) - floor(time/3600)) * 60)), (["", "0"] select (floor time / 60 - floor time / 60 * 60 < 10)) + str (floor(((time/60) - floor(time/60)) * 60))]];
date params ["_year", "_month", "_day", "_hours", "_minutes"];
ctrlSetText [
IDC_DISPLAY_DATEANDTIME,
format ["%1/%2/%3 %4:%5", [_day, 2] call CBA_fnc_formatNumber, [_month, 2] call CBA_fnc_formatNumber, _year, [_hours, 2] call CBA_fnc_formatNumber, [_minutes, 2] call CBA_fnc_formatNumber]
];

private _time = time;
private _hours = floor (_time / 3600);
private _minutes = floor ((_time / 60) - (_hours * 60));
private _seconds = floor (_time % 60);
ctrlSetText [IDC_DISPLAY_ELAPSEDTIME, format ["%1:%2:%3", [_hours, 2] call CBA_fnc_formatNumber, [_minutes, 2] call CBA_fnc_formatNumber, [_seconds, 2] call CBA_fnc_formatNumber]];

if (GVAR(AEDX_MonitorTarget) getVariable [QGVAR(AED_X_VitalsMonitor_Connected), false]) then {
private _partIndex = ((GVAR(AEDX_MonitorTarget) getVariable [QGVAR(AED_X_VitalsMonitor_Provider), [-1, -1, -1]]) select 2);
Expand Down
10 changes: 8 additions & 2 deletions addons/circulation/functions/fnc_AEDX_ViewMonitor_CPR.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,14 @@ private _dlg = uiNamespace getVariable ["KAT_Circulation_AEDX_Monitor_Display",

// Handle date and time display - [year,month,day,hour,min]

(_dlg displayCtrl IDC_DISPLAY_DATEANDTIME_TITLE) ctrlSetText (format ["%1/%2/%3 %4:%5", (["", "0"] select (date select 2 < 10)) + str (date select 2), (["", "0"] select (date select 1 < 10)) + str (date select 1), date select 0, (["", "0"] select (date select 3 < 10)) + str (date select 3), (["", "0"] select (date select 4 < 10)) + str (date select 4)]);
(_dlg displayCtrl IDC_DISPLAY_ELAPSEDTIME_TITLE) ctrlSetText (format ["%1:%2:%3", (["", "0"] select (floor time / 3600 < 10)) + str (floor(time/3600)), (["", "0"] select (floor time / 3600 - floor time / 3600 * 60 < 10)) + str (floor(((time/3600) - floor(time/3600)) * 60)), (["", "0"] select (floor time / 60 - floor time / 60 * 60 < 10)) + str (floor(((time/60) - floor(time/60)) * 60))]);
date params ["_year", "_month", "_day", "_hours", "_minutes"];
(_dlg displayCtrl IDC_DISPLAY_DATEANDTIME_TITLE) ctrlSetText (format ["%1/%2/%3 %4:%5", [_day, 2] call CBA_fnc_formatNumber, [_month, 2] call CBA_fnc_formatNumber, _year, [_hours, 2] call CBA_fnc_formatNumber, [_minutes, 2] call CBA_fnc_formatNumber]);

private _time = time;
private _hours = floor (_time / 3600);
private _minutes = floor ((_time / 60) - (_hours * 60));
private _seconds = floor (_time % 60);
(_dlg displayCtrl IDC_DISPLAY_ELAPSEDTIME_TITLE) ctrlSetText (format ["%1:%2:%3", [_hours, 2] call CBA_fnc_formatNumber, [_minutes, 2] call CBA_fnc_formatNumber, [_seconds, 2] call CBA_fnc_formatNumber]);

if (GVAR(AEDX_MonitorTarget_Title) getVariable [QGVAR(AED_X_VitalsMonitor_Connected), false]) then {
private _partIndex = ((GVAR(AEDX_MonitorTarget_Title) getVariable [QGVAR(AED_X_VitalsMonitor_Provider), [-1, -1, -1]]) select 2);
Expand Down
4 changes: 3 additions & 1 deletion addons/circulation/functions/fnc_CPRStart.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ if (_notInVehicle) then {

// Format time to minutes:seconds
private _CPRTime = CBA_missionTime - _CPRStartTime;
private _time = format ["%1:%2",(["", "0"] select (floor _CPRTime / 3600 - floor _CPRTime / 3600 * 60 < 10)) + str (floor(((_CPRTime/3600) - floor(_CPRTime/3600)) * 60)), (["", "0"] select (floor _CPRTime / 60 - floor _CPRTime / 60 * 60 < 10)) + str (floor(((_CPRTime/60) - floor(_CPRTime/60)) * 60))];
private _minutes = floor (_CPRTime / 60);
private _seconds = floor (_CPRTime % 60);
private _time = format ["%1:%2", [_minutes, 2] call CBA_fnc_formatNumber, [_seconds, 2] call CBA_fnc_formatNumber];

[_patient, "activity", LSTRING(Activity_CPR), [[_medic, false, true] call ACEFUNC(common,getName), _time]] call ACEFUNC(medical_treatment,addToLog);

Expand Down

0 comments on commit 18a1652

Please sign in to comment.