#define JANUARY 1
#define FEBRUARY 2
#define MARCH 3
#define APRIL 4
#define MAY 5
#define JUNE 6
#define JULY 7
#define AUGUST 8
#define SEPTEMBER 9
#define OCTOBER 10
#define NOVEMBER 11
#define DECEMBER 12
#define MONDAY 0
#define TUESDAY 1
#define WEDNESDAY 2
#define THURSDAY 3
#define FRIDAY 4
#define SATURDAY 5
#define SUNDAY 6
native GetMonthName(month); //number of month OR the NAME of the month in CAPITAL LETTERS
native GetDayName(day); // NUMBER of DAY or name of DAY in CAPITAL letters [0 TO 6]
native GetCurrentMonth(); // returns the current month
native GetCurrentDay(); // returns the current DATE
native IsLeapYear(year); // returns if the INPUT YEAR is a LEAP YEAR
native GetMonthDays(month); // RETURNS THE NUMBER OF DAYS OF THE INPUT MONTH
native GetDay(date, month, year); // returns the >> DAY << (NOT DATE)
main()
{
printf("%s", GetDayName(GetDay(15, JULY, 2013)) );
}
There are ways of working out what day any date in history was - programs don't store big lists they just work it out on the fly.
|
I found these: http://www.wikihow.com/Calculate-the-Day-of-the-Week they're written for mental calculation, but I'm sure there are ways to port them to code. I also found this JavaScript, but again don't know how reliable it is:
http://www.sislands.com/coin70/week3/dayofwk.htm A cursory glance looks OK, and don't forget that PAWN already has integer division represented in that code by Math.floor. |
stock GetDay(day, month, year)
{
if (month < 3)
{
month += 12;
year--;
}
return ((13*month+3)/5 + day + year + year/4 - year/100 + year/400) % 7;
}
Hmm.. What's the sole(or main, or however you describe it) function of this include? Maybe I can get this, but what about the other beginners who can't get this?
|
It can be used for many things!
The day on which the player registered, Can be used as an extra param in TIMESTAMP's Use your imagination, there are endless possibilities if you really want to use the functions. I use this in my server for - Getting the day on which the server registered (provided I save the date,month,year) Getting the day on which the player was banned/will be unbanned [provided the date,month,year] Setting up a local-server clock @****** - thanks for pointing that out, updated the define's, any idea what I should replace % 7 with so that I can use numbers 1 to 7? |
pawn Code: main() { printf("%s", GetDayName(GetDay(15, JULY, 2013)) ); } |
How i see in-game what day it is?
And about : Give me that errors: ....: error 029: invalid expression, assumed zero .... : error 017: undefined symbol "x" ... : warning 215: expression has no effect ... : warning 209: function "GetDay" should return a value ... : error 021: symbol already defined: "main" A command like /calendar ...would be useful... ( if you have time,can tell me how to do that please? ) Question:After that , the time is 1 minute=60 seconds,i want to be 1 minute=1 second ,what i have to change? I'm begginer,so i ask what i don't understand,i hope that don't upset you. |
stock GetDay(day, month, year)
{
if (month < 3)
{
month += 12;
year--;
}
return ((13*month+3)/5 + day + year + year/4 - year/100 + year/400) % 7;
}
How i see in-game what day it is?
And about : Give me that errors: ....: error 029: invalid expression, assumed zero .... : error 017: undefined symbol "x" ... : warning 215: expression has no effect ... : warning 209: function "GetDay" should return a value ... : error 021: symbol already defined: "main" A command like /calendar ...would be useful... ( if you have time,can tell me how to do that please? ) Question:After that , the time is 1 minute=60 seconds,i want to be 1 minute=1 second ,what i have to change? I'm begginer,so i ask what i don't understand,i hope that don't upset you. |
stock GetDay(day, month, year) { if (month < 3) { month += 12; year--; } return ((13*month+3)/5 + day + year + year/4 - year/100 + year/400) % 7; }
stock IsLeapYear(year)
{
if(year % 4 == 0)
{
if(year % 100 == 0 && year % 400 != 0) return 0;
else return 1;
}
else return 0;
}
Correction...
pawn Код:
|