04.01.2013, 19:01
(
Last edited by gabyk; 21/01/2013 at 02:08 PM.
)
a_timefunctions
Include
IntroductionInclude
Creator: Armyw0w ( PAWN Team )
Credits: FarSe ( Expiry date scheme )
Description: This include uses 3 timing functions.
Original topic: Click here
Download
(All copyrights go to © GTA-MP Romania)
Functions
Update 0.2
Fix bug at A_DifferenceTime.
Added A_FormatTime function.
- A_CalculateDate ( year, month, day, hour, minute, second )
- A_ExpireDate ( year, month, day, hour, minute, second )
- A_Difference_Second ( first_second, second_second ) ** Works only with A_DifferenceDate
- A_Difference_Minute ( first_minute, second_minute ) ** Works only with A_DifferenceDate
- A_Difference_Hour ( first_hour, second_hour ) ** Works only with A_DifferenceDate
- A_Difference_Day ( first_day, second_day ) ** Works only with A_DifferenceDate
- A_Difference_Month ( first_month, second_month ) ** Works only with A_DifferenceDate
- A_Difference_Year ( first_year, second_year ) ** Works only with A_DifferenceDate
- A_DifferenceDate ( year, month, day, hour, minute, second )
- A_FormatTime ( year, month, day, hour, minute, second )
Use
1. A_CalculateDate
This function is used for calculating a future date. What does this mean? Let's say we have the following time: (actual time) (22:07) and we want it 10 hours forward. A normal calculator would result 32, but this include will cronologically calculate it, so the calculated time will be 08:07 AM.
pawn Code:
new year, month, day, hour = 10, min, sec;
A_CalculateDate ( year, month, day, hour, min, sec );
printf ( "%d:%d:%d %d/%d/%d", hour, min, sec, day, month, year );
After calculating, the result will be the chronologically calculated date.
So if the current date is (21:17:0 4/1/2013), the result will be:
pawn Code:
7:17:0 5/1/2013
This function is used for checking if the current date passes the stabilised date.
pawn Code:
new year, month, day, hour, min, sec;
getdate ( year, month, day ), gettime ( hour, min, sec );
if ( A_ExpireDate ( 2013, 1, 5, 21, 30, 0 ) )
{
print ( "It passed 5/1/2013 21:30:0!" );
} else {
print ( "It isn't yet 5/1/2013 21:30:0!" );
}
3. A_DifferenceDate
This function differences two dates.
pawn Code:
A_Difference_Second ( 0, 0 );
A_Difference_Minute ( 42, 42 );
A_Difference_Hour ( 21, 19 );
A_Difference_Day ( 4, 4 );
A_Difference_Month ( 1, 1 );
A_Difference_Year ( 2013, 2013 );
new year, month, day, hour, min, sec;
A_Difference_Date ( year, month, day, hour, min, sec );
printf ( "%d:%d:%d %d/%d/%d", hour, min, sec, day, month, year );
pawn Code:
2:0:0 0/0/0
4. A_FormatTime
Ok, so the function A_FormatTime will return with a text ( ex: month: 3, days: 5, minutes: 39, seconds: 15 )
If from years to seconds the value is 0, it doesn't will show.
Ex: If year and mounth have the value 0, it doesn't appear.
pawn Code:
printf ( "You still have to wait: %s", A_FormatTime ( 0, 0, 5, 0, 0, 0 ) );
pawn Code:
You still have to wait: days: 5, hours: 0, minutes: 0, seconds: 0
The end
This include is made for GTA-MP Romanian Community.
Thank you!