• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Problem with ctime
#1
Hey im using southclaws pawn-ctime version (https://github.com/Southclaws/pawn-ctime) and actually got a problem with my function "WhichDayWillItBe".

It worked fine before with Ryders version.



Function:

Code:
stock WhichDayWillItBe(const iDay)

{

? ? new

? ? ? ? tmWhichDay[e_tm],

? ? ? ? thedate[6];



? ? localtime(Time:gettime(), tmWhichDay);

? ?

? ? tmWhichDay[tm_mday] = iDay;



? ? mktime(tmWhichDay);

?

? ? strftime(thedate, sizeof(thedate), "%d.%m", tmWhichDay);

? ? return thedate;

}





Example:

Code:
hook OnGameModeInit()

{

? ? for(new i = 0; i < 20; i)

? ? {

? ? ? ? new formdate[6], whichday2;

? ? ? ? whichday2 = -i;

? ? ? ? format(formdate, sizeof(formdate), "%s",WhichDayWillItBe(whichday2));

? ? ? ? printf("Whichday[%d]: %s",i,formdate);

? ? }



? ? return 1;

}





Returns:

Code:
[02:49:57] Whichday[0]: 14.09



... working fine till first day of a month but then:



[02:49:57] Whichday[12]: 02.09



[02:49:57] Whichday[13]: 01.09



[02:49:57] Whichday[14]: 00.09



[02:49:57] Whichday[15]: -1.09



[02:49:57] Whichday[16]: -2.09



[02:49:57] Whichday[17]: -3.09



[02:49:57] Whichday[18]: -4.09



[02:49:57] Whichday[19]: -5.09





Im using this to get the last 7 days in dd.mm format, after 01.09 it should actually show 31.08 but returns 00.09 ... -1.09 for me



Hope someone can help me with that.
  Reply


Forum Jump: