Strlib Warning
#8

EDIT: Okay, it needed to add + 1 to the length of "form" and forgot to copy to form2 while testing it.

PHP код:
GetTimeStamp(form[])
{
    new 
form2[16], hourminutesecondHour[5], Minute[5], Second[5], AmPm[5];
    
gettime(hourminutesecond);
    
strcat(form2formstrlen(form) + 1);
    if(
strfind(form"tt"false) != -1format(AmPmsizeof(AmPm), "%s", (hour >= 12) ? ("PM") : ("AM")),
    
hour = (hour 12) ? (hour 12) : (hour), strreplace(form2"tt"AmPmtrue);
    if(
strfind(form"hh"true) != -1format(Hoursizeof(Hour), "%02d"hour), strreplace(form2"hh"Hourtrue);
    else if(
strfind(form"h"true) != -1format(Hoursizeof(Hour), "%d"hour), strreplace(form2"h"Hourtrue);
    if(
strfind(form"mm"true) != -1format(Minutesizeof(Minute), "%02d"minute), strreplace(form2"mm"Minutetrue);
    else if(
strfind(form"m"true) != -1format(Minutesizeof(Minute), "%d"minute), strreplace(form2"m"Minutetrue);
    if(
strfind(form"ss"true) != -1format(Secondsizeof(Second), "%02d"second), strreplace(form2"ss"Secondtrue);
    else if(
strfind(form"s"true) != -1format(Secondsizeof(Second), "%d"second), strreplace(form2"s"Secondtrue);
    return 
form2;

PHP код:
print(GetTimeStamp("hh:mm:ss tt")); 
PHP код:
// Output:
04:57:03 PM 
EDIT 2: Yeah, I get weird results with "h:m tt" - I'll check it again and reply back.
Reply


Messages In This Thread
Strlib Warning - by bgedition - 12.05.2015, 13:06
Re: Strlib Warning - by Konstantinos - 12.05.2015, 13:11
Re: Strlib Warning - by bgedition - 12.05.2015, 13:14
Re: Strlib Warning - by Konstantinos - 12.05.2015, 13:18
Re: Strlib Warning - by bgedition - 12.05.2015, 13:21
Re: Strlib Warning - by Konstantinos - 12.05.2015, 13:30
Re: Strlib Warning - by bgedition - 12.05.2015, 13:34
Re: Strlib Warning - by Konstantinos - 12.05.2015, 13:38
Re: Strlib Warning - by bgedition - 12.05.2015, 13:52
Re: Strlib Warning - by Konstantinos - 12.05.2015, 14:26

Forum Jump:


Users browsing this thread: 5 Guest(s)