[Include] uDate
#1

Welcome!

I want to show my new include. I think a lot of people had that problem, that s/he can't convert the famous Unix time to date. It wasn't be possible, because the SA-MP didn't insured a function for this. With this code you can convert the Unix time easily to date. (hour, and minute GMT are contain)

But let's see the code while using it:
Код:
	new
		time = gettime(),
		y, mo, d, h, mi, s
	;
	printf("Unix: %d", time);
	uDate(time, y, mo, d, h, mi, s);
	printf("%d|%d|%d|%d|%d|%d|", y, mo, d, h, mi, s);
The code will print this:
Код:
[22:44:12] Unix: 1356471852
[22:44:12] 2012|12|25|22|44|12|
Download:
http://pastebin.com/Lzrt8jrZ

If you find any bug in the code, please post the bug in this topic, or please send me a private message!

(Sorry for the English mistake)
Reply
#2

Wasn't already released something similar?
Reply
#3

Bug when using Unix small example: Unix: 10, crash occurs.
Reply
#4

Fixed!
Reply
#5

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
Wasn't already released something similar?
Yes, but so what? Does that mean for example that we must go into threads with new ini file systems and ask whether something similar wasn't already released?

Anyways, thanks for sharing Drake1994.
Reply
#6

gettime() native function for Unix Time stamp is already bugged. I posted the fixes also on thread to get Date from a Unix time Stamp. Fixed ****** version of mktime() as well as Jochemd include for getting the data from a timestamp.

Click here for the Fixes.
Reply
#7

Well to tell the truth i didn't found any bug in gettime(), it return the time in second in GMT +0.
And the gettime() depends on how the machine's time is set, because it return the time of the machine.

Here is the proof:
Код:
public OnFilterScriptInit()
{
	HTTP(0, HTTP_GET, "webadmin.gc4.hu/asd.php", "", "TestIt");
	return true;
}

forward TestIt(index, response_code, data[]);
public TestIt(index, response_code, data[])
{
	printf("%d", gettime());
	print(data);
}
The code will print this:
Код:
[15:36:54] 1356705414
[15:36:54] 1356705416
The first line is the gettime() function.
The second line is the PHP time() function.
Reply
#8

Quote:
Originally Posted by Drake1994
Посмотреть сообщение
Well to tell the truth i didn't found any bug in gettime(), it return the time in second in GMT +0.
And the gettime() depends on how the machine's time is set, because it return the time of the machine.

Here is the proof:
Код:
public OnFilterScriptInit()
{
	HTTP(0, HTTP_GET, "webadmin.gc4.hu/asd.php", "", "TestIt");
	return true;
}

forward TestIt(index, response_code, data[]);
public TestIt(index, response_code, data[])
{
	printf("%d", gettime());
	print(data);
}
The code will print this:
Код:
[15:36:54] 1356705414
[15:36:54] 1356705416
The first line is the gettime() function.
The second line is the PHP time() function.
Yeah! Should be same for all the TimeZones that is the bug. For +5:30 TimeZones. That is the way you can fix it.
Reply
#9

But the gettime() return in GMT + 0, and with this code, you can easily add hour GMT, and minute GMT.

Example:
Код:
uDate(time, y, mo, d, h, mi, s, 5, 30);
Reply
#10

Check Jochemd's Unix Time Stamp to Date include. Does the same ! Try using your include in GMT + 5: 30. You will get to know what problem occurs and how to fix it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)