Advertisement
Johurt

[FNC] GetDateAsTimestamp (GMT +2)

Oct 1st, 2014
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.72 KB | None | 0 0
  1. /*
  2.         By Johurt, 2014/10/01
  3.     mktime ( http://wiki.sa-mp.com/wiki/Useful_Functions#mktime ) function analog
  4. */
  5. stock GetDateAsTimestamp(yy, mm, dd, hh, mins, secs) // GMT +2 (Vilnius)
  6. {
  7.     new timestamp, metu_skirtumas = yy - 1970, c, menesio_dienos[12];
  8.     timestamp = (metu_skirtumas * 31536000) + ((dd-1) * 86400) + ((hh-3) * 3600) + (mins * 60) + secs;
  9.     if(mm > 1)
  10.     {
  11.             menesio_dienos = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  12.         for(c = 0; c < mm-1; c++)
  13.         {
  14.             timestamp += (menesio_dienos[c] * 86400);
  15.             }
  16.     }
  17.     for(c = 0; c < metu_skirtumas; c++)
  18.     {
  19.         if((((1970 + c + 1) % 4 == 0) && ((1970 + c + 1) % 100 != 0)) || ((1970 + c + 1) % 400 == 0)) timestamp += 86400;
  20.     }
  21.     return timestamp;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement