Calculate days between two dates
#3

Alright now i took another try:

pawn Код:
CalculateDaysBetweenDates(d1,m1,y1,d2,m2,y2)
{
    d2-=d1;
    if(y1!=y2)
    {
        while(y1!=y2)
        {
            printf("%i;%i;%i;%i", d2,m1,y1,ddiff);
            ddiff+=days[m1-1];
            m1++;
            if(m1==13)
            {
                y1++;
                m1=1;
            }
            printf("%i;%i;%i;%i", d2,m1,y1,ddiff);
        }
        ddiff+=d2;
        return ddiff;
    }
    else if(y1==y2)
    {
        if(m1!=m2)
        {
            while(m1!=m2)
            {
                printf("%i;%i;%i;%i", d2,m1,y1,ddiff);
                ddiff+=days[m1-1];
                m1++;
                if(m1==13)
                {
                    y1++;
                    m1=1;
                }
                printf("%i;%i;%i;%i", d2,m1,y1,ddiff);
            }
            ddiff+=d2;
            return ddiff;
        }
        else if(m1==m2)
        {
            return d2;
        }
        else return print("Calculation Error");
    }
    else return print("Calculation Error");
}
I think for the beginning this should be enough. It doesn't calculate the gay-februaries correctly, yet, but that won't be that complicated.
#Edit: If anybody doesn't understand the reason why there are so many printf's, it's for me to see if everythign works fine.
Reply


Messages In This Thread
Calculate days between two dates - by DeathOnaStick - 09.09.2010, 17:51
Re: Calculate days between two dates - by Kyosaur - 09.09.2010, 18:05
Re: Calculate days between two dates - by DeathOnaStick - 10.09.2010, 13:46

Forum Jump:


Users browsing this thread: 1 Guest(s)