for some reason the calculations I try to perform are getting wrong results, if anyone sees anything I don't please tell me

usual output count being minus several thousands to plus several thousands, but never starting at 0 as it should, after start it keeps counting the number it output correctly

Code:
#include <acknex.h>
#include <default.c>

double start_time = 0;
double passed_time = 0;

STRING* debug_string1 = "";
STRING* debug_string2 = "";
STRING* debug_string3 = "";

FONT* debug_font = "Arial#20b";

TEXT* debug_text =
{
	pos_x = 0;
	pos_y = 0;
	string(debug_string1, debug_string2, debug_string3);
	font = debug_font;
	flags = VISIBLE;
}

function main()
{
	level_load(NULL);
	
        //start of program as date in seconds
	start_time = (sys_year - 1) * 365;
	start_time = (start_time + sys_doy - 1) * 24;
	start_time = (start_time + sys_hours) * 60;
	start_time = (start_time + sys_minutes) * 60;
	start_time = start_time + sys_seconds;

	//some debug info
	str_for_float(debug_string1, start_time);
	str_cat(debug_string1, " ");
	str_cat(debug_string1, str_for_int(NULL, sys_year));
	str_cat(debug_string1, "/");
	str_cat(debug_string1, str_for_int(NULL, sys_doy));
	str_cat(debug_string1, " ");
	str_cat(debug_string1, str_for_int(NULL, sys_hours));
	str_cat(debug_string1, ":");
	str_cat(debug_string1, str_for_int(NULL, sys_minutes));
	str_cat(debug_string1, ":");
	str_cat(debug_string1, str_for_int(NULL, sys_seconds));
	
	while(1)
	{
                //current date in seconds
		passed_time = (sys_year - 1) * 365;
		passed_time = (passed_time + sys_doy - 1) * 24;
		passed_time = (passed_time + sys_hours) * 60;
		passed_time = (passed_time + sys_minutes) * 60;
		passed_time = passed_time + sys_seconds;


		//some more debug info
		str_for_float(debug_string2, passed_time);
		str_cat(debug_string2, " ");
		str_cat(debug_string2, str_for_int(NULL, sys_year));
		str_cat(debug_string2, "/");
		str_cat(debug_string2, str_for_int(NULL, sys_doy));
		str_cat(debug_string2, " ");
		str_cat(debug_string2, str_for_int(NULL, sys_hours));
		str_cat(debug_string2, ":");
		str_cat(debug_string2, str_for_int(NULL, sys_minutes));
		str_cat(debug_string2, ":");
		str_cat(debug_string2, str_for_int(NULL, sys_seconds));
		
		str_for_float(debug_string3, (passed_time - start_time));
		wait(-0.1);
	}
}


also why does panel editor crash?