[Plugin] mtime Time Plugin [UnixTime convert, Regular Time Convert and more]
#1

THIS PROJECT IS OUTDATED AND NO LONGER MAINTAINED. DO NOT USE IT AS IT CONTAINS SECURITY VULNERABILITIES AND BUGS.

« mtime »
time plugin

v2.1


Author: Mellnik
Current Version: v2.1
Release Date: 24/11/2012


Information


This plugin provides different time functions and time convert methods.

At the moment, there are 4 natives, I will explain them below:
(If a parameter is written in italic - it is optional)

mtime_UnixToDate(dest[], unixseconds, date, timeformat);


Description:
It simply converts UnixTime to a readable date.
By default date is set to DATE_LITTLEENDIAN and timeformat to CLOCK_EUROPEAN

There are three formats for the date and two for the clock format.
Код:
DATE_LITTLEENDIAN -> Day.Month.Year
DATE_BIGENDIAN    -> Year.Month.Day
DATE_MIDDLEENDIAN -> Month.Day.Year
Calendar date - Wikipedia

Код:
CLOCK_EUROPEAN -> Hour in 24h format:Minute:Second
CLOCK_AMERICAN -> Hour in 12h format:Minute:Second (AM or PM designation)
Example:
Код:
new string[40];
mtime_UnixToDate(string, 1353777478);
print(string);

// Output: 24.11.2012 - 18:17:58
Another example:
Код:
new string[40];
mtime_UnixToDate(string, gettime(), DATE_MIDDLEENDIAN, CLOCK_AMERICAN); // gettime() returns current date in unixtime
print(string);

// Possible output: 11.24.2012 - 06:17:58 PM

mtime_ToRegularTime(dest[], msecs, bool:use_hrs);


Description:
It converts milliseconds to hours:minutes:seconds:milliseconds.
Example
Код:
new string[45];
mtime_ToRegularTime(string, 38193856);
print(string);

// Output: 10:36:33.856
Код:
new string[45];
mtime_ToRegularTime(string, 381938, false);
print(string);

// Output: 06:21.938

mtime_GetLocalTime(dest[], date, timeformat);


Description:
Gets localtime of the OS. See mtime_UnixToDate() for the date and timeformat params
Example:
Код:
new string[30];
mtime_GetLocalTime(string);
print(string);

// Possible output: 24.11.2012 - 18:44:41
Код:
new string[30];
mtime_GetLocalTime(string, DATE_MIDDLEENDIAN, CLOCK_AMERICAN);
print(string);

// Possible output: 11.24.2012 - 06:44:41 PM

mtime_GetServerUptime();


Description:
Returns the uptime of the SAMP server in seconds.
Example:
Код:
new uptime = mtime_GetServerUptime();

// uptime is now equal to the elapsed seconds since the plugin has been loaded

Download:


http://files.mellnik.com/old/


Changelog:
  • v2.1 (04/08/2013)
    • Fixed bugs in v2.0
  • v2.0 (03/08/2013)
    • Moved to github
    • Redesigned some natives
    • Cleaned up and improved the code
  • v1.1 (28/02/2013)
    • Fixed mtime_GetServerUptime() for Linux
    • Removed the type param in mtime_GetServerUptime()
    • Re-managed the code
    • Fixed -O in makefile
    • Fixed several crashes due to buffer overflows
    • Optimized some code
  • v1.0 (24/11/2012)
    • Initial Release

License:


mtime is licensed under MPL 2.0
Reply
#2

this is rather a good start with c++ :O
Reply
#3

I agree with what you said. Everything can be scriptable in PAWN, also C++ is faster than PAWN but however is not noticeable on this case. Good job anyways
Reply
#4

Very usefull plugin
Reply
#5

Really nice ,thanks.
Reply
#6

Thank you for creating this! This is just what I needed! Originally I was sending a HTTP request to a PHP script, then using the response, but this was slow, and this is the perfect solution!

Good work!
Reply
#7

Quote:
Originally Posted by Bicentric
Посмотреть сообщение
Thank you for creating this! This is just what I needed! Originally I was sending a HTTP request to a PHP script, then using the response, but this was slow, and this is the perfect solution!

Good work!
NP But please report any bugs you may find.
Reply
#8

Thank you for making this, very useful!
Reply
#9

Good job !
Reply
#10

Nice work, i could use this ! ^^
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)