private static int[] gDateAjust(int yg, int mg, int dg){
	    	int[] out = new int[3];
	        int dys;
	        //
	        out[0] = yg;
	        out[1] = mg;
	        out[2] = dg;
	        /* Make sure that dates are within the correct values */
	        /*  Underflow  */
	        if (out[1] < 1)
	        {
	            /* months underflow */
	        	out[1] += 12;
	            /* plus as the underflow months is negative */
	        	out[0]--;
	        }
	         
	        if (out[2] < 1)
	        {
	            /* days underflow */
	        	out[1]--;
	            /* month becomes the previous month */
	        	out[2] += gmonth[out[1]];
	            /* number of days of the month less the underflow days (it is plus as the sign of the day is negative) */
	            if (out[1] == 2)
	            	out[2] += gLeapYear(out[0]);
	             
	            if (out[1] < 1)
	            {
	                /* months underflow */
	            	out[1] += 12 ;
	                /* plus as the underflow months is negative */
	                out[0]--;
	            }
	             
	        }
	         
	        /* Overflow  */
	        if (out[1] > 12)
	        {
	            /* months */
	        	out[1] -= 12;
	        	out[0]++;
	        }
	         
	        if (out[1] == 2)
	            dys = gmonth[out[1]] + gLeapYear(out[0]);
	        else
	            /* number of days in the current month */
	            dys = gmonth[out[1]]; 
	        if (out[2] > dys)
	        {
	            /* days overflow */
	        	out[2] -= dys;
	        	out[1]++;
	            if (out[1] == 2)
	            {
	                dys = gmonth[out[1]] + gLeapYear(out[0]);
	                /* number of days in the current month */
	                if (out[2] > dys)
	                {
	                	out[2] -= dys;
	                	out[1]++;
	                }
	                 
	            }
	             
	            if (out[1] > 12)
	            {
	                /* months */
	            	out[1] -= 12;
	            	out[0]++;
	            }
	             
	        }
	         return out;
	    }