13.11.2013, 08:33
Plugin-free strftime
Introduction
Yes, this is the same one I've released almost a year ago, but this version is fixed up.
So there is a plugin released here which allows scripters to use the strftime function in PAWN. However, I wasn't going to use an entire plugin just for one function when I can replicate it in PAWN!
I could of used the HTTP function, but nobody wants to put an extra file on their webhost. And the HTTP function is really slow.
How it works
Let's say it was Saturday, and I wanted to get the day of the week:
Or if I wanted to get today's date AND time:
Or perhaps I want to get the PM or AM designation:
The possibilities are endless!
Functions
There are 2 functions:
Formats the time using the specifiers from string[] and stores the value into dest[].
Example:
Basically a wrapper for strftime. Returns the result instead of storing it inside a value.
Example:
List of specifiers
Download
Solidfiles
Introduction
Yes, this is the same one I've released almost a year ago, but this version is fixed up.
So there is a plugin released here which allows scripters to use the strftime function in PAWN. However, I wasn't going to use an entire plugin just for one function when I can replicate it in PAWN!
I could of used the HTTP function, but nobody wants to put an extra file on their webhost. And the HTTP function is really slow.
How it works
Let's say it was Saturday, and I wanted to get the day of the week:
pawn Код:
new str[32];
strftime("Today is %A.", str);
print(str);
Код:
[23:23:15] Today is Saturday.
pawn Код:
new str[32];
strftime("%x %X", str);
print(str);
Код:
[23:23:29] 11/10/2013 23:23:29
pawn Код:
nwe str[32];
strftime("Time: %I:%M %p", str);
print(str);
Код:
[23:23:37] Time: 11:23 PM
Functions
There are 2 functions:
pawn Код:
strftime(const string[], dest[]);
Example:
pawn Код:
new str[24];
strftime("%I:%M %p", str);
print(str);
pawn Код:
format_time(const string[]);
Example:
pawn Код:
print(format_time("%I:%M %p"));
Код:
%a - Abbreviated weekday name %A - Full weekday name %b - Abbreviated month name %B - Full month name %c - Date and time representation %d - Day of the month (01-31) %H - Hour in 24h format (00-23) %I - Hour in 12h format (01-12) %j - Day of the year (001-366) %m - Month as a decimal number (01-12) %M - Minute (00-59) %p - AM or PM designation %S - Second (00-61) %U - Week number with the first Sunday as the first day of week one (00-53) %w - Weekday as a decimal number with Sunday as 0 (0-6) %W - Week number with the first Monday as the first day of week one (00-53) %x - Date representation %X - Time representation %y - Year, last two digits (00-99) %Y - Year %% - A % sign
Solidfiles