Get the day of the week - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Get the day of the week (
/showthread.php?tid=284612)
Get the day of the week -
MP2 - 19.09.2011
How do you make a function to return the week DAY? By this I mean Monday, Tuesday, Wednesday etc.
Re: Get the day of the week -
dowster - 20.09.2011
******.com
Edit: i know this link is in LUA but im trying to translate it best i can at the moment,
http://lua-users.org/wiki/DayOfWeekA...InMonthExample
Re: Get the day of the week -
SourceCode - 20.09.2011
pawn Code:
stock GetWeek(d,m,y) //by drakins,thanks vine
{
m=(m-=2);
if(m<=0) --y,m+=12;
return ( ((
(d+((13*m-1)/5)+(y%100)+((y%100)/4)+(((y%100)%100)/4)-2*(y%100))%7) == 0)?
(((d+((13*m-1)/5)+(y%100)+((y%100)/4)+(((y%100)%100)/4
)-2*(y%100))%7) + 1) : (((d+((13*m-1)/5)+(y%100)+((y%100)/4)+
(((y%100)%100)/4)-2*(y%100))%7)
) );
}
Quote:
#define GetWeek() ((getdate() % 0x7) + 0x6)
|
Re: Get the day of the week - Emmet_ - 20.09.2011
Edited. Misunderstood the post. D;
Re: Get the day of the week -
SourceCode - 20.09.2011
Quote:
Originally Posted by Emmet_
This should do the trick.
pawn Code:
stock ReturnWeekDay() { new weekday[16]; year, month, day; getdate(year, month, day); switch(month) { case 1: weekday = "January"; case 2: weekday = "February"; case 3: weekday = "March"; case 4: weekday = "April"; case 5: weekday = "May"; case 6: weekday = "June"; case 7: weekday = "July"; case 8: weekday = "August"; case 9: weekday = "September"; case 10: weekday = "October"; case 11: weekday = "November"; case 12: weekday = "December"; default: weekday = "Unknown"; } return weekday; }
He meant to return the weekday such as Monday, Tuesday, Wednesday.
|
uR Code gives month not the day
Re: Get the day of the week - Emmet_ - 20.09.2011
Quote:
Originally Posted by SourceCode
uR Code gives month not the day
|
FAIL! Thanks for mentioning that!