Jalali date ?!
#1

Hello,
Recently I started to script again ...
I am searching for a converter of Gregorian date to Jalali date.
Found a C script for this ... and I changed it to pawn.
Jalali = Hijri Shamsi
Here is this :
pawn Код:
#include <a_samp>
#define                             COLOR_LIGHTRED                    0xFF6347AA
forward MiladiToShamsi(iMiladiMonth,iMiladiDay,iMiladiYear);
public MiladiToShamsi(iMiladiMonth,iMiladiDay,iMiladiYear)
{

    new shamsiDay, shamsiMonth, shamsiYear;
    new dayCount,farvardinDayDiff,deyDayDiff ;
    new sumDayMiladiMonth[] = {0,31,59,90,120,151,181,212,243,273,304,334};
    new sumDayMiladiMonthLeap[]= {0,31,60,91,121,152,182,213,244,274,305,335};



    farvardinDayDiff=79;


    if (MiladiIsLeap(iMiladiYear))
    {
        dayCount = sumDayMiladiMonthLeap[iMiladiMonth-1] + iMiladiDay;
    }
    else
    {
        dayCount = sumDayMiladiMonth[iMiladiMonth-1] + iMiladiDay;
    }
    if((MiladiIsLeap(iMiladiYear - 1)))
    {
        deyDayDiff = 11;
    }
    else
    {
        deyDayDiff = 10;
    }
    if (dayCount > farvardinDayDiff)
    {
        dayCount = dayCount - farvardinDayDiff;
        if (dayCount <= 186)
        {
            switch (dayCount%31)
            {
                case 0:
                {
                    shamsiMonth = dayCount / 31;
                    shamsiDay = 31;
                }
                default:
                {
                    shamsiMonth = (dayCount / 31) + 1;
                    shamsiDay = (dayCount%31);
                }
            }
            shamsiYear = iMiladiYear - 621;
        }
        else
        {
            dayCount = dayCount - 186;
            switch (dayCount%30)
            {
                case 0:
                {
                    shamsiMonth = (dayCount / 30) + 6;
                    shamsiDay = 30;
                }
                default:
                {
                    shamsiMonth = (dayCount / 30) + 7;
                    shamsiDay = (dayCount%30);

                }
            }
            shamsiYear = iMiladiYear - 621;
        }
/*      else
        {
        dayCount = dayCount + deyDayDiff;


        switch (dayCount%30)
        {
                case 0 :
                {
                    shamsiMonth = (dayCount / 30) + 9;
                    shamsiDay = 30;
                }
                default:
                {
                    shamsiMonth = (dayCount / 30) + 10;
                    shamsiDay = (dayCount%30);
                }
        }
        shamsiYear = iMiladiYear - 622;
        }
*/

    }
    new strx[64];
    format(strx, sizeof(strx), "%d/%d/%d", shamsiYear, shamsiMonth, shamsiDay);
    SendClientMessageToAll(COLOR_LIGHTRED, strx);
    return 1;
}


// the function check a miladiyear is leap or not.
forward MiladiIsLeap(miladiYear);
public MiladiIsLeap(miladiYear)
{
if(((miladiYear % 100)!= 0 && (miladiYear % 4) == 0) || ((miladiYear % 100)== 0 && (miladiYear % 400) == 0))
return 1;
else
return 0;
}
Keeps error ...
Any help ?
Reply
#2

What errors are you receiving?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)