Advertisement
mrdrifter

GetTimeToDate

Feb 22nd, 2014
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.16 KB | None | 0 0
  1.  
  2. stock GetTimeToDate(time_start, time_str[])
  3. {  
  4.         new secs = time_start - gettime();
  5.         if( secs < 0 )
  6.         {
  7.             format( time_str, 20, "-");
  8.             return 0;
  9.         }
  10.         new Lat = secs / 31556926 % 12;
  11.         new Miesiecy = secs / 604800 % 52;
  12.         new Dni = secs / 86400 % 7;
  13.         new Godzin = secs / 3600 % 24;
  14.         new Minut = secs / 60 % 60;
  15.         new time = secs % 60;
  16.        
  17.         #if defined dli
  18.             #undef dli
  19.         #endif
  20.         #define dli(%1,%2,%3,%4) ((%1==1)?(%2):(((%1% 10>1)&&(%1% 10<5)&&!((%1% 100>=10)&&(%1% 100<=21)))?(%3):(%4)))
  21.  
  22.         if( Lat > 0 ) format( time_str, 20, "%d %s", dli(Lat, "roku", "lat", "lat"));
  23.         else if( Miesiecy > 0 ) format( time_str, 20, "%d %s",Miesiecy, dli(Miesiecy,"miesiąca","Miesiecy","Miesiecy"));
  24.         else if( Dni > 0 ) format( time_str, 20, "%d %s",Dni, dli(Dni,"dnia","dni","dni"));
  25.         else if( Godzin > 0 ) format( time_str, 20, "%d %s",Godzin, dli(Godzin,"godzina", "godziny","godzin"));
  26.         else if( Minut > 0 ) format( time_str, 20, "%d %s",Minut, dli(Minut,"minuta","minuty","minut"));
  27.         else if( time > 0 ) format( time_str, 20, "%d %s",secs, dli(secs,"sekunda","sekundy","sekund"));
  28.        
  29.         #undef dli
  30.        
  31.         return 1;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement