Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Functions.
- ( ZTime v0.01 - Zume-Zero ).
- - Changelog v0.01:
- * GetDayOfWeek(day, month, year); - Gets the name of the day / Example: "Sábado" (GetDayOfWeek(23, 8, 2014)).
- - Código basando en "La Congruencia de Zeller" (http://es.wikipedia.org/wiki/Congruencia_de_Zeller).
- * GetDate(); - Get date in format "Sábado 23 de Agosto del 2014".
- * GetTime(); - Get time of the SAMP-SERVER.EXE in format "08:47:56".
- * GetMonthName(month); - Get name of month
- * IsLeapDay(year); - Checks if the year is leap year or not
- */
- #include <a_samp>
- stock GetMonthName(month){
- new m_[10];
- switch(month){
- case 1: format(m_, sizeof(m_), "January");
- case 2: format(m_, sizeof(m_), "February");
- case 3: format(m_, sizeof(m_), "March");
- case 4: format(m_, sizeof(m_), "April");
- case 5: format(m_, sizeof(m_), "May");
- case 6: format(m_, sizeof(m_), "June");
- case 7: format(m_, sizeof(m_), "July");
- case 8: format(m_, sizeof(m_), "August");
- case 9: format(m_, sizeof(m_), "September");
- case 10: format(m_, sizeof(m_), "October");
- case 11: format(m_, sizeof(m_), "November");
- case 12: format(m_, sizeof(m_), "December");
- }
- return m_;
- }
- stock GetDayOfWeek(day, month, year){
- new d_[4], m_[10];
- d_[0] = (14-month) / 12, d_[2] = year - d_[0], d_[1] = month + (12*d_[0]) - 2;
- d_[3] = (day + d_[2] + (d_[2]/4) - (d_[2]/100) + (d_[2]/400) + (31*d_[1]) / 12) % 7;
- if(d_[3] == 0) d_[3] = 7;
- switch(d_[3]){
- case 1: format(m_, sizeof(m_), "Monday");
- case 2: format(m_, sizeof(m_), "Tuesday");
- case 3: format(m_, sizeof(m_), "Wednesday");
- case 4: format(m_, sizeof(m_), "Thursday");
- case 5: format(m_, sizeof(m_), "Friday");
- case 6: format(m_, sizeof(m_), "Saturday");
- case 7: format(m_, sizeof(m_), "Sunday");
- }
- return m_;
- }
- stock GetTime(){
- new
- m_[34],
- d_[3];
- gettime(d_[0], d_[1], d_[2]), format(m_, sizeof(m_), "%02d:%02d:%02d", d_[0], d_[1], d_[2]);
- return m_;
- }
- stock GetDate(){
- new
- m_[34],
- d_[3];
- getdate(d_[0], d_[1], d_[2]);
- format(m_, sizeof(m_), "%s %d de %s of %d", GetDayOfWeek(d_[0], d_[1], d_[2]), d_[2], GetMonthName(d_[1]), d_[0]);
- return m_;
- }
- stock IsLeapDay(year){
- return ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement