<commit_before>private ["_currentDate"];

waitUntil{!isNil "bis_fnc_init"};

if (timeSync == 3) exitwith {
    if (isnil "timeSeasons") then {timeSeasons = 6};
    if (isnil "timeHour") then {timeHour = 12};
    if (isnil "timeMinute") then {timeMinute = 00};

    setdate [2012,timeSeasons,28,timeHour,timeMinute];
    diag_log format["MSO-%1 Time Sync off: Date %2", time, date];
};

CRB_timeSync = {
        private ["_timeSync","_update","_sdate","_cdate","_syr","_smt","_sdy","_shr","_smn","_cyr","_cmt","_cdy","_chr","_cmn"];
        _sdate = _this;
        _cdate = date;
        
        _syr = _sdate select 0;
        _smt = _sdate select 1;
        _sdy = _sdate select 2;
        _shr = _sdate select 3;
        _smn = _sdate select 4;
        
        _cyr = _cdate select 0;
        _cmt = _cdate select 1;
        _cdy = _cdate select 2;
        _chr = _cdate select 3;
        _cmn = _cdate select 4;
        
        _update = false;
        _timeSync = timeSync;
        
        
        // Do any of the MAJOR date values differ?
        if(
                _syr != _cyr ||
                _smt != _cmt ||
                _sdy != _cdy ||
                _shr != _chr
        ) then {
                // We'll need setDate to sync
                _timeSync = 2;
                _update = true;
        };
        
        // Do just the minutes differ?
        if(_smn != _cmn) then {
                _update = true;
        };
        
        // Do we need to sync?
        if(_update) then {
                switch (_timeSync) do {
                        // Monitor only
                        case 0: {
                                diag_log format["MSO-%1 Time Sync: Monitor S %2 C %3", time, _sdate, _cdate];
                        };
                        // Use skipTime if possible
                        case 1: {
                                skipTime ((_smn - _cmn) / 60);
                                diag_log format["MSO-%1 Time Sync: skipTime S %2 C %3 N %4", time, _sdate, _cdate, date];
                        };
                        // Use setDate
                        case 2: {
                                setDate _sdate;
                                diag_log format["MSO-%1 Time Sync: setDate S %2 C %3 N %4", time, _sdate, _cdate, date];

                        };
                };
        };
};

if (isserver) then {        
        if(isNil "timeSync") then {
                timeSync = 2;
        };
        
        if(isNil "timeOptions") then {
                timeOptions = 0;
        };
        
        if(isNil "timeSeasons") then {
                timeSeasons = 3;
        };
        
        if(isNil "timeHour") then {
                timeHour = 8;
        };
        
        if(isNil "timeMinute") then {
                timeMinute = 0;
        };
        
        // Set server time if required
        switch (timeOptions) do {
                // Original
                case 0: {
                };
                // Random
                case 1: {
                        _currentDate = date;
                        _currentDate set [1, [12,3,6,9] call BIS_fnc_selectRandom];
                        _currentDate set [2, 22];
                        _currentDate set [3, floor(random 24)];
                        _currentDate set [4, floor(random 60)];
                        setDate _currentDate;
                };
                // Custom
                case 2: {
                        _currentDate = date;
                        _currentDate set [1, timeSeasons];
                        _currentDate set [2, 22];
                        _currentDate set [3, timeHour];
                        _currentDate set [4, timeMinute];
                        setDate _currentDate;
                };
        };
        
        timeSync spawn {
                private ["_delay"];
                _delay = 1;
                CRB_TIME = date;
                publicvariable "CRB_TIME";
                waitUntil{
                        CRB_TIME = date;
                        publicvariable "CRB_TIME";
                        sleep _delay;
                        false;
                };
        };
        
};

if(!isDedicated) then {
        "CRB_TIME" addPublicVariableEventHandler {CRB_TIME call CRB_timeSync;};
        
        waitUntil{!isNil "CRB_TIME"};
        
        setDate CRB_TIME;
};<commit_msg>[CRB_TIMESYNC] - Disabled time sync by default<commit_after>private ["_currentDate"];

waitUntil{!isNil "bis_fnc_init"};

CRB_timeSync = {
        private ["_timeSync","_update","_sdate","_cdate","_syr","_smt","_sdy","_shr","_smn","_cyr","_cmt","_cdy","_chr","_cmn"];
        _sdate = _this;
        _cdate = date;
        
        _syr = _sdate select 0;
        _smt = _sdate select 1;
        _sdy = _sdate select 2;
        _shr = _sdate select 3;
        _smn = _sdate select 4;
        
        _cyr = _cdate select 0;
        _cmt = _cdate select 1;
        _cdy = _cdate select 2;
        _chr = _cdate select 3;
        _cmn = _cdate select 4;
        
        _update = false;
        _timeSync = timeSync;
        
        
        // Do any of the MAJOR date values differ?
        if(
                _syr != _cyr ||
                _smt != _cmt ||
                _sdy != _cdy ||
                _shr != _chr
        ) then {
                // We'll need setDate to sync
                _timeSync = 2;
                _update = true;
        };
        
        // Do just the minutes differ?
        if(_smn != _cmn) then {
                _update = true;
        };
        
        // Do we need to sync?
        if(_update) then {
                switch (_timeSync) do {
                        // Monitor only
                        case 0: {
                                diag_log format["MSO-%1 Time Sync: Monitor S %2 C %3", time, _sdate, _cdate];
                        };
                        // Use skipTime if possible
                        case 1: {
                                skipTime ((_smn - _cmn) / 60);
                                diag_log format["MSO-%1 Time Sync: skipTime S %2 C %3 N %4", time, _sdate, _cdate, date];
                        };
                        // Use setDate
                        case 2: {
                                setDate _sdate;
                                diag_log format["MSO-%1 Time Sync: setDate S %2 C %3 N %4", time, _sdate, _cdate, date];

                        };
                };
        };
};

if (isserver) then {        
        if(isNil "timeSync") then {
                timeSync = 2;
        };
        
        if(isNil "timeOptions") then {
                timeOptions = 0;
        };
        
        if(isNil "timeSeasons") then {
                timeSeasons = 3;
        };
        
        if(isNil "timeHour") then {
                timeHour = 8;
        };
        
        if(isNil "timeMinute") then {
                timeMinute = 0;
        };
        
        // Set server time if required
        switch (timeOptions) do {
                // Original
                case 0: {
                };
                // Random
                case 1: {
                        _currentDate = date;
                        _currentDate set [1, [12,3,6,9] call BIS_fnc_selectRandom];
                        _currentDate set [2, 22];
                        _currentDate set [3, floor(random 24)];
                        _currentDate set [4, floor(random 60)];
                        setDate _currentDate;
                };
                // Custom
                case 2: {
                        _currentDate = date;
                        _currentDate set [1, timeSeasons];
                        _currentDate set [2, 22];
                        _currentDate set [3, timeHour];
                        _currentDate set [4, timeMinute];
                        setDate _currentDate;
                };
        };

	// Time sync off
	if (timeSync == 3) then {
	    diag_log format["MSO-%1 Time Sync off: Date %2", time, date];
	} else {       
	        timeSync spawn {
        	        private ["_delay"];
                	_delay = 1;
                	waitUntil{
                        	CRB_TIME = date;
	                        publicvariable "CRB_TIME";
        	                sleep _delay;
                	        false;
	                };
        	};
        };
};

if(!isDedicated && timeSync != 3) then {
        "CRB_TIME" addPublicVariableEventHandler {CRB_TIME call CRB_timeSync;};
        
        waitUntil{!isNil "CRB_TIME"};
        
        setDate CRB_TIME;
};
{'fraction_non_alphanumeric': 0.09635899814471242, 'fraction_numerical': 0.015306122448979591, 'mean_word_length': 0.9786648313833448, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5892352', 'n_tokens_mistral': 2588, 'n_tokens_neox': 2356, 'n_words': 617}