RealTime and Hour [+REP]
#3

after 30 seconds search
Quote:
Originally Posted by Red_Dragon.
Посмотреть сообщение
I searched for something similar to this a while ago and I got two snippets saved.
pawn Код:
stock GetDayName(d=0,m=0,y=0) {
    /*
    0=Invalid date
    1=Sunday
    2=Monday
    ...
    7=Saturday
    */

    if(d==0&&m==0&&y==0) { //set to today if no values passed
        getdate(y, m, d);
    }

    new month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
        i;

    if (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0))
        month[1] = 29;

    if (y < 1900 || m < 1 || m > 12 || d < 1 || d > month[m - 1])
        return 0;

    for (i = 1900; i < y; i++) {
        if (i % 4 == 0 && (i % 100 != 0 || i % 400 == 0))
            d += 366;
        else
            d += 365;
    }

    for (i = 0; i < m - 1; i++) {
        d += month[i];
    }

    return d%7+1;
}
And
pawn Код:
switch(GetDayName())
{
    case 1: //Sunday
    case 2: //Monday
    case 3: //Tuesday
    case 4: //Wednesday
    case 5: //Thursday
    case 6: //Friday
    case 7: //Saturday
    default: //error
}
Reply


Messages In This Thread
RealTime and Hour [+REP] - by arlindi - 20.01.2015, 13:06
Re: RealTime and Hour [+REP] - by Kaperstone - 20.01.2015, 13:14
Re: RealTime and Hour [+REP] - by xVIP3Rx - 20.01.2015, 13:23
Re: RealTime and Hour [+REP] - by arlindi - 20.01.2015, 13:42
Re: RealTime and Hour [+REP] - by xVIP3Rx - 20.01.2015, 13:52
Re: RealTime and Hour [+REP] - by arlindi - 20.01.2015, 13:54
Re: RealTime and Hour [+REP] - by xVIP3Rx - 20.01.2015, 13:59
Re: RealTime and Hour [+REP] - by arlindi - 20.01.2015, 14:02
Re: RealTime and Hour [+REP] - by xVIP3Rx - 20.01.2015, 14:06
Re: RealTime and Hour [+REP] - by arlindi - 20.01.2015, 14:09

Forum Jump:


Users browsing this thread: 1 Guest(s)