I am taking a string from player's file and it would look like this: 20110502 and I would like get it in this form: 02/05/2011 with '/'. How can I do it? I think I would need to get it backward and then after two numbers put /. But how to do it?
pawn Код:
new date[3][11];
new dateString[11]="00/00/0000";
split(dateString, date,'/');
new day = strval(date[0]);
new month = strval(date[1]);
new year = strval(date[2]);
if(day < 1 || day > 31) SendClientMessage(playerid, -1 ,"Day can only be from 1 to 31.");
if(month < 1 || month > 12) SendClientMessage(playerid, -1,"Month can only be from 1 to 12.");
if(year < 1) SendClientMessage(playerid, -1,"Year can be less than 1.");
stock split(const strsrc[], strdest[][], delimiter)
{
new i, li;
new aNum;
new len;
while(i <= strlen(strsrc))
{
if(strsrc[i] == delimiter || i == strlen(strsrc))
{
len = strmid(strdest[aNum], strsrc, li, i, 128);
strdest[aNum][len] = 0;
li = i+1;
aNum++;
}
i++;
}
return 1;
}