SA-MP Forums Archive
[Include] uDate - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] uDate (/showthread.php?tid=402719)



uDate - Drake1994 - 27.12.2012

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)


Re: uDate - TheArcher - 27.12.2012

Wasn't already released something similar?


Re: uDate - paulor - 27.12.2012

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


Re: uDate - Drake1994 - 28.12.2012

Fixed!


Re: uDate - Prumpuz - 28.12.2012

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.


Re: uDate - Ballu Miaa - 28.12.2012

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.


Re: uDate - Drake1994 - 28.12.2012

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.


Re: uDate - Ballu Miaa - 28.12.2012

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.


Re: uDate - Drake1994 - 28.12.2012

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);



Re: uDate - Ballu Miaa - 29.12.2012

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.