Raised This Month: $32 Target: $400
 8% 

FormatTime messed up..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheWho
AlliedModders Donor
Join Date: Jul 2012
Old 01-01-2016 , 17:35   FormatTime messed up..
Reply With Quote #1

Hey,

FormatTime is restarting from 1970 when I want to format a high valued timestamp and so my date get messed up, example:

PHP Code:
new String:buffer[64];
FormatTime(buffersizeof(buffer), "%H:%M %d.%b.%Y"4733510400);
PrintToServer("Time: %s"buffer); 
Output:
HTML Code:
Time: 18:31 24.Nov.1983
But the actual date would be:
HTML Code:
00:00 01.Jan.2120
I did use http://www.unixtimestamp.com/index.php to generate this example timestamp.
Some ideas/help?
TheWho is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 01-01-2016 , 17:55   Re: FormatTime messed up..
Reply With Quote #2

That happens because PAWN's only data type is cell, which is a 32bit integer. 4733510400 exceeds int32's max value, and therefore isn't a valid integer value in PAWN. When you subtract max unsigned int32 value (which is 4294967295) from the given timestamp, you get:
Code:
4733510400 - 4294967295 = 438543105
which is the timestamp for the date you got as output.

Last edited by klippy; 01-01-2016 at 17:55.
klippy is offline
TheWho
AlliedModders Donor
Join Date: Jul 2012
Old 01-01-2016 , 18:31   Re: FormatTime messed up..
Reply With Quote #3

Damn, I kinda knew it, thanks!
I don't want to mess around with the date by splitting the number and calculating the date of each split, and later add them together again to get the correct time, this is to dirty
TheWho is offline
TheWho
AlliedModders Donor
Join Date: Jul 2012
Old 01-01-2016 , 21:59   Re: FormatTime messed up..
Reply With Quote #5

Stupid me <_<
TheWho is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode