Need Function | Day
#1

i need a function that returns the name of day.. like Monday or sunday etc

Please I need it for my server :P
Reply
#2

Well here is a good answer to you.

Click Here.

It's day/time "system"
Reply
#3

Or you can use a custom function, although I am not sure if it still works.
pawn Код:
GetWeekDay(day=0, month=0, year=0) // By Weirdosport (I think)
{
    if (!day) getdate(year, month, day);
    new weekday_str[10], j, e;
    if (month <= 2)
    {
        month += 12;
        --year;
    }
    j = year % 100;
    e = year / 100;
    switch ((day + (month+1)*26/10 + j + j/4 + e/4 - 2*e) % 7)
    {
        case 0: weekday_str = "Saturday";
        case 1: weekday_str = "Sunday";
        case 2: weekday_str = "Monday";
        case 3: weekday_str = "Tuesday";
        case 4: weekday_str = "Wednesday";
        case 5: weekday_str = "Thursday";
        case 6: weekday_str = "Friday";
    }
    return weekday_str;
}
Reply
#4

Quote:
Originally Posted by Dwane
Посмотреть сообщение
Or you can use a custom function, although I am not sure if it still works.
pawn Код:
GetWeekDay(day=0, month=0, year=0);
Thank you !!!!!
Reply
#5

Quote:
Originally Posted by dr.lozer
Посмотреть сообщение
Thank you !!!!!
You're welcome. Although, I have tested and it gets the name of the day, but +2.
You need to change the switch with the following one;
pawn Код:
// --
    switch( ( day + ( month + 1 ) * 26 / 10 + j + j / 4 + e / 4 - 2 * e ) % 7 )
    {
        case 0: weekday_str = "Thursday";
        case 1: weekday_str = "Friday";
        case 2: weekday_str = "Saturday";
        case 3: weekday_str = "Sunday";
        case 4: weekday_str = "Monday";
        case 5: weekday_str = "Tuesday";
        case 6: weekday_str = "Wednesday";
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)