Advertisement
CreativityLacker

[Include] Days [BETA VERSION 1]

May 15th, 2013
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. /*
  4. native GetMonthName(month); //number of month OR the NAME of the month in CAPITAL LETTERS
  5. native GetDayName(day); // NUMBER of DAY or name of DAY in CAPITAL letters
  6. native GetCurrentMonth(); // returns the current month
  7. native GetCurrentDay(); // returns the current DATE
  8. native IsLeapYear(year); // returns if the INPUT YEAR is a LEAP YEAR
  9. native GetMonthDays(month); // RETURNS THE NUMBER OF DAYS OF THE INPUT MONTH
  10. native GetDay(date, month, year); // returns the >> DAY << (NOT DATE)
  11. */
  12.  
  13. #define JANUARY 1
  14. #define FEBRUARY 2
  15. #define MARCH 3
  16. #define APRIL 4
  17. #define MAY 5
  18. #define JUNE 6
  19. #define JULY 7
  20. #define AUGUST 8
  21. #define SEPTEMBER 9
  22. #define OCTOBER 10
  23. #define NOVEMBER 11
  24. #define DECEMBER 12
  25.  
  26. #define MONDAY 1
  27. #define TUESDAY 2
  28. #define WEDNESDAY 3
  29. #define THURSDAY 4
  30. #define FRIDAY 5
  31. #define SATURDAY 6
  32. #define SUNDAY 7
  33.  
  34. stock GetMonthName(month)
  35. {
  36. new ma[20];
  37. switch(month)
  38. {
  39. case JANUARY: ma = "January";
  40. case FEBRUARY: ma = "February";
  41. case MARCH: ma = "March";
  42. case APRIL: ma = "April";
  43. case MAY: ma = "May";
  44. case JUNE: ma = "June";
  45. case JULY: ma = "July";
  46. case AUGUST: ma = "August";
  47. case SEPTEMBER: ma = "September";
  48. case OCTOBER: ma = "October";
  49. case NOVEMBER: ma = "November";
  50. case DECEMBER: ma = "December";
  51. }
  52. return ma;
  53. }
  54.  
  55. stock GetDayName(day)
  56. {
  57. new da[20];
  58. switch(day)
  59. {
  60. case 1: da = "Monday";
  61. case 2: da = "Tuesday";
  62. case 3: da = "Wednesday";
  63. case 4: da = "Thursday";
  64. case 5: da = "Friday";
  65. case 6: da = "Saturday";
  66. case 7: da = "Sunday";
  67. }
  68. return da;
  69. }
  70.  
  71. stock GetCurrentMonth()
  72. {
  73. new date[3];
  74. getdate(date[0], date[1], date[2]);
  75. return date[1];
  76. }
  77.  
  78. stock GetCurrentDay()
  79. {
  80. new date[3];
  81. getdate(date[0], date[1], date[2]);
  82. return date[2];
  83. }
  84.  
  85. stock IsLeapYear(year)
  86. {
  87. if(year % 4 == 0)
  88. {
  89. if(year % 100 == 0 && year % 400 != 0) return 0;
  90. else return 1;
  91. }
  92. else return 0;
  93. }
  94.  
  95. stock GetMonthDays(month)
  96. {
  97. if(month == JANUARY) return 31;
  98. else if(month == FEBRUARY)
  99. {
  100. new date[3];
  101. getdate(date[0], date[1], date[2]);
  102. if(IsLeapYear(date[0]) == 1) return 29;
  103. else return 28;
  104. }
  105. else if(month == MARCH) return 31;
  106. else if(month == APRIL) return 30;
  107. else if(month == MAY) return 31;
  108. else if(month == JUNE) return 30;
  109. else if(month == JULY) return 31;
  110. else if(month == AUGUST) return 31;
  111. else if(month == SEPTEMBER) return 30;
  112. else if(month == OCTOBER) return 31;
  113. else if(month == NOVEMBER) return 30;
  114. else if(month == DECEMBER) return 31;
  115. }
  116.  
  117. stock GetDay(day, month, year)
  118. {
  119. if (month < 3)
  120. {
  121. month += 12;
  122. year--;
  123. }
  124. return (((13*month+3)/5 + day + year + year/4 - year/100 + year/400) % 7)+1;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement