SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 31/10/2011, 07:27 AM   #11
RyDeR`
High-roller
 
RyDeR`'s Avatar
 
Join Date: Feb 2009
Location: Belgium
Posts: 3,058
Reputation: 696
Default Re: CTime Library

Quote:
Originally Posted by Gamer_Z View Post
any Unix-timestamp conversions available?
Plugin could come in handy though sometimes.. ;P
You can use "localtime" or "gmtime" (depending which you need) to convert timestamps to the tm structure. For example let's pick a random timestamp "254545645"
pawn Code:
new
    tm <tmStamp>
;
localtime(254545645, tmStamp);
   
static
    szStr[64]
;
strftime(szStr, sizeof(szStr), "%A %d %B %Y, %H:%M:%S", tmStamp); // Result: "Wednesday 25 January 1978, 04:07:25"
printf(szStr);
And to convert from tm structure to a timestamp use "mktime".

Quote:
Originally Posted by _[HuN]_Epsilon_ View Post
linux?
I have no Linux installed right now. Will do it and post here when I'm done compiling.

If anyone else can compile to for Linux, please go ahead. And thanks for the comments.
__________________

Sup?
RyDeR` is offline   Reply With Quote
Old 31/10/2011, 08:16 AM   #12
steki.
High-roller
 
steki.'s Avatar
 
Join Date: Nov 2010
Location: São Paulo, Brasil
Posts: 2,571
Reputation: 315
Default Re: CTime Library

THIS IS AWESOME!

Any chances of that little code to pseudo-random generator?
__________________
Rio
steki. is offline   Reply With Quote
Old 31/10/2011, 10:02 AM   #13
KoczkaHUN
Gangsta
 
KoczkaHUN's Avatar
 
Join Date: Jan 2010
Posts: 516
Reputation: 100
Default Re: CTime Library

could be useful, but why a plugin?
__________________
uıɐƃɐ oɔsǝʇ uı pɹɐoqʎǝʞ ʎnq ʇou llıʍ ı
-
Quote:
Originally Posted by WackoX
If i steal a television at a store, am i still legal if i put a sign on it saying "COPYRIGHT © ELECTRONIC STORE"?
Quote:
[20:46:02] <balintx> What is the output of this PAWN code? printf("%d", random(100));
[20:46:11] <JaTochNietDan> WHO THE FUCK KNOWS
-
KoczkaHUN is offline   Reply With Quote
Old 31/10/2011, 11:12 AM   #14
TheArcher
High-roller
 
TheArcher's Avatar
 
Join Date: Dec 2009
Location: Home
Posts: 2,417
Reputation: 251
Default Re: CTime Library

Amazing work, this will help a lot.
__________________
TheArcher is offline   Reply With Quote
Old 31/10/2011, 02:01 PM   #15
Gamer_Z
Banned
 
Join Date: Jun 2009
Posts: 1,848
Reputation: 1370
Default Re: CTime Library

Quote:
Originally Posted by KoczkaHUN View Post
could be useful, but why a plugin?
SA-MP natives don't have this featuers, yes you can make it however the plugin will beat the crap out of stock pawn functions if it get's to speed here.

Also, making it in pawn is not always that perfect if it gets to date calculation, I see many functions around here and they pretty much sux... Almost all of them are very limited or simply return wrong data.

@RyDeR`, thanks for you explaination, I think I'm going to use this in my next project (Gamemode)
Gamer_Z is offline   Reply With Quote
Old 31/10/2011, 03:36 PM   #16
CyNiC
High-roller
 
Join Date: Jan 2009
Location: Brazil
Posts: 1,443
Reputation: 203
Default Re: CTime Library

CTime.so compiled on Ubuntu 10.04 LTS: http://solidfiles.com/d/bd850/
__________________
My scripts
Brazucas'Server
CyNiC is offline   Reply With Quote
Old 31/10/2011, 03:51 PM   #17
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 15,127
Reputation: 3170
Default Re: CTime Library

Quote:
Originally Posted by Gamer_Z View Post
SA-MP natives don't have this featuers, yes you can make it however the plugin will beat the crap out of stock pawn functions if it get's to speed here.

Also, making it in pawn is not always that perfect if it gets to date calculation, I see many functions around here and they pretty much sux... Almost all of them are very limited or simply return wrong data.

@RyDeR`, thanks for you explaination, I think I'm going to use this in my next project (Gamemode)
Dates and times are a NIGHTMARE to work with (I just happen to have been reading up on them a lot recently). People have timezones (and they're not all exact hours apart (Kathmandu is UTC +05:41:16)), daylight savings (that don't happen the same every year and as Russia have just proved, may not happen at all), leap years (and leap seconds), multiple calendars (some not even 356 days long), changing calendars, changing timezones (even within one country (or state)).

And don't even start on relativistic effects (time depends on your current velocity) - I doubt that applies to SA:MP, but is VERY applicable when working with GPS as the satellites are going so fast, and is the explanation behind the recent "discovery" that neutrinos travel faster than light.

Have fun!

Edit: I forgot to mention, this all only applies when you're working with dates since 1970 and before 2038 - outside that range you're even more screwed!
Y_Less is offline   Reply With Quote
Old 31/10/2011, 03:58 PM   #18
Gamer_Z
Banned
 
Join Date: Jun 2009
Posts: 1,848
Reputation: 1370
Default Re: CTime Library

Quote:
Originally Posted by Y_Less View Post
recent "discovery" that neutrinos travel faster than light.
Hmm, All Physics universities in Netherlands can now burn all their books cuz they thought nothing can be faster than light. Nice discovery, I already smell the burnt books

What good to know that my GPS is only dependent on the position GTA gives to it, not on time XD (Well it's dependent on time from another point of view...)


Also Y_Less, people will move to 64 bit, or even 128 bit numbers which will give us 'some' more time so you won't we screwd that hard outside 1970 - 2038

And well, I personally think speed, velocity etc is something unlimited, you just have problems getting very fast because people don't know how to build up such great speeds
Gamer_Z is offline   Reply With Quote
Old 31/10/2011, 04:17 PM   #19
Y_Less
Beta Tester
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 15,127
Reputation: 3170
Default Re: CTime Library

Quote:
Originally Posted by Gamer_Z View Post
Hmm, All Physics universities in Netherlands can now burn all their books cuz they thought nothing can be faster than light. Nice discovery, I already smell the burnt books
I put "discovery" in quotes because it was disproved for exactly this reason.

Quote:
Originally Posted by Gamer_Z View Post
Also Y_Less, people will move to 64 bit, or even 128 bit numbers which will give us 'some' more time so you won't we screwd that hard outside 1970 - 2038
Not in SA:MP, but yes, 64bit should keep us going for a while (around 300 billion years).
Y_Less is offline   Reply With Quote
Old 31/10/2011, 04:21 PM   #20
Gamer_Z
Banned
 
Join Date: Jun 2009
Posts: 1,848
Reputation: 1370
Default Re: CTime Library

Quote:
Originally Posted by Y_Less View Post
I put "discovery" in quotes because it was disproved for exactly this reason.
Okay

Quote:
Not in SA:MP, but yes, 64bit should keep us going for a while (around 300 billion years).
Well if SA-MP survives to 2037 I surely will be suprised.
Gamer_Z is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS]Vehicle Library Sandra18[NL] Filterscripts 10 04/07/2013 11:34 AM
[Include] Neon Library Shelby Lançamentos/Releases 21 19/06/2011 01:23 PM
SQLite, RAW or library Luka P. Help Archive 2 15/09/2010 04:28 PM
[Map] [MAP]Los Santos Library Juanmv Maps 18 13/02/2010 06:23 AM


All times are GMT. The time now is 09:53 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.