Advertisement
ZumeZero

[Include] zTime SA:MP ENG

Aug 24th, 2014
660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.29 KB | None | 0 0
  1. /* Functions.
  2.  
  3.     ( ZTime v0.01 - Zume-Zero ).
  4.    
  5.     - Changelog v0.01:
  6.         * GetDayOfWeek(day, month, year); - Gets the name of the day / Example: "Sábado" (GetDayOfWeek(23, 8, 2014)).
  7.             - Código basando en "La Congruencia de Zeller" (http://es.wikipedia.org/wiki/Congruencia_de_Zeller).
  8.  
  9.         * GetDate(); - Get date in format "Sábado 23 de Agosto del 2014".
  10.         * GetTime(); - Get time of the SAMP-SERVER.EXE in format "08:47:56".
  11.         * GetMonthName(month); - Get name of month
  12.         * IsLeapDay(year); - Checks if the year is leap year or not
  13.  
  14. */
  15.  
  16. #include <a_samp>
  17.  
  18. stock GetMonthName(month){
  19.     new m_[10];
  20.     switch(month){
  21.         case 1: format(m_, sizeof(m_), "January");
  22.         case 2: format(m_, sizeof(m_), "February");
  23.         case 3: format(m_, sizeof(m_), "March");
  24.         case 4: format(m_, sizeof(m_), "April");
  25.         case 5: format(m_, sizeof(m_), "May");
  26.         case 6: format(m_, sizeof(m_), "June");
  27.         case 7: format(m_, sizeof(m_), "July");
  28.         case 8: format(m_, sizeof(m_), "August");
  29.         case 9: format(m_, sizeof(m_), "September");
  30.         case 10: format(m_, sizeof(m_), "October");
  31.         case 11: format(m_, sizeof(m_), "November");
  32.         case 12: format(m_, sizeof(m_), "December");
  33.     }
  34.     return m_;
  35. }
  36.  
  37. stock GetDayOfWeek(day, month, year){
  38.     new d_[4], m_[10];
  39.     d_[0] = (14-month) / 12, d_[2] = year - d_[0], d_[1] = month + (12*d_[0]) - 2;
  40.     d_[3] = (day + d_[2] + (d_[2]/4) - (d_[2]/100) + (d_[2]/400) + (31*d_[1]) / 12) % 7;
  41.     if(d_[3] == 0) d_[3] = 7;
  42.     switch(d_[3]){
  43.         case 1: format(m_, sizeof(m_), "Monday");
  44.         case 2: format(m_, sizeof(m_), "Tuesday");
  45.         case 3: format(m_, sizeof(m_), "Wednesday");
  46.         case 4: format(m_, sizeof(m_), "Thursday");
  47.         case 5: format(m_, sizeof(m_), "Friday");
  48.         case 6: format(m_, sizeof(m_), "Saturday");
  49.         case 7: format(m_, sizeof(m_), "Sunday");
  50.     }
  51.     return m_;
  52. }
  53.  
  54. stock GetTime(){
  55.     new
  56.         m_[34],
  57.         d_[3];
  58.        
  59.     gettime(d_[0], d_[1], d_[2]), format(m_, sizeof(m_), "%02d:%02d:%02d", d_[0], d_[1], d_[2]);
  60.     return m_;
  61. }
  62.  
  63. stock GetDate(){
  64.     new
  65.         m_[34],
  66.         d_[3];
  67.        
  68.     getdate(d_[0], d_[1], d_[2]);
  69.     format(m_, sizeof(m_), "%s %d de %s of %d", GetDayOfWeek(d_[0], d_[1], d_[2]), d_[2], GetMonthName(d_[1]), d_[0]);
  70.     return m_;
  71. }
  72.  
  73. stock IsLeapDay(year){
  74.     return ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement