SA-MP Forums Archive
[HELP] datecmp - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] datecmp (/showthread.php?tid=288694)



[HELP] datecmp - roleplay501 - 08.10.2011

Hello, im trying to make function to compare between dates.
The output should be formated string (YYYY-MM-DD), ANYWAY..
Thats what i made so far.. i've not checked it yet
But i'm feeling that something not clear with the MATH in it.

It should return number of years, months and days.
//for example. 2011/10/08 to 1993/11/15
//Output will be
//17 Years
//11 Months
// 23 Days
**As far as i know there is few months that contain 31 days~28days but there is no-way to check it and to get the correct number of the days between two dates...

Hope you'll help me to make it work perfect with the correct number of days.

stock datecmp(year, month, day)
{
new cy, cm, cd;
getdate(cy, cm, cd);

new y, m, d;
y = cy - year;

if(cm < month)
m = month - cm;
if(cm > month)
m = cm - month;

if(cd < day)
d = day - cd;
if(cd > day)
d = cd - day;

new string[12];
format(string,12,"%04d-%02d-%02d", y, m, d);
return(string);
}


Re: [HELP] datecmp - roleplay501 - 09.10.2011

?