SA-MP Forums Archive
[Include] dth_time - (Un)format the time - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] dth_time - (Un)format the time (/showthread.php?tid=585421)



dth_time - (Un)format the time - Dutheil - 13.08.2015

dth_time v0.1 - (Un)format the time
An include with 2 functions allowing you to (un)format a time.
Contents :
Informations :
The functions are based on a particular format.

Before using this include, you must specify the language you use on your gamemode.
PHP код:
enum
{
    
FR// French
    
EN// English
    
PT// Portuguese
    
PL// Polish
    
ES// Spanish
    
DE // German
}
#define LANGUAGE FR 
PHP код:
native ReturnSecondByDate(const duration[]);
native ReturnDateBySecond(time); 
Exemple thйorique :
  • 2 days 5 hours 30 minutes et 15 secondes : 2d5h30m15s (192 615 secondes)
  • 2 days 5 hours et 30 minutes : 2d5h30m (192 600 secondes)
  • 2 days et 30 minutes : 2d30m (174 600 secondes)
  • 2 days et 15 secondes : 2d15s (172 815 secondes)
  • 5 hours et 30 minutes : 5h30m (19 800 secondes)
Exemple d'utilisation :
PHP код:
main()
{
    print(
"_____________________");
    print(
"ReturnSecondByDate");
    
    
printf("2j5h30m15s : %d"ReturnSecondByDate("2j5h30m15s"));
    
printf("2j5h30m : %d"ReturnSecondByDate("2j5h30m"));
    
printf("2j30m : %d"ReturnSecondByDate("2j30m"));
    
printf("2j15s : %d"ReturnSecondByDate("2j15s"));
    
printf("5h30m : %d"ReturnSecondByDate("5h30m"));
    
    print(
"_____________________");
    print(
"ReturnDateBySecond");
    
    
printf("192 615 : %s"ReturnDateBySecond(192615));
    
printf("192 600 : %s"ReturnDateBySecond(192600));
    
printf("174 600 : %s"ReturnDateBySecond(174600));
    
printf("172 815 : %s"ReturnDateBySecond(172815));
    
printf("19 800 : %s"ReturnDateBySecond(19800));

Very useful for temporary commands (ban, mute, jail...) : "/ban Player 1h30m The reason"

Download :






Re: dth_time - (Un)format the time - hamzajaved780 - 13.08.2015

Haven't seen the code, but great work. Love new additions in samp


Re : Re: dth_time - (Un)format the time - Dutheil - 13.08.2015

It is very easy aha, thanks !