Guest User

Untitled

a guest
Jul 15th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. new day,month,year;
  2. new Day,Month,Year;
  3. day = Strtok(string,0,'/');
  4. month = Strtok(string,1,'/');
  5. year = Strtok(string,2,'/');
  6. new seconds = mktime(0,0,0,day,month,year);
  7. new Seconds = gettime();
  8. new sec = Seconds - seconds;
  9.  
  10. new Day = (((sec % 60) % 60)%24);
  11. new Month = ((((sec % 60) % 60)%24)%30);
  12. new Year = (((((sec % 60) % 60)%24)%30)%12);
  13.  
  14.  
  15.  
  16. Strtok(const string[], index,splitchar)
  17. {
  18. new length = strlen(string);
  19. while ((index < length) && (string[index] <= splitchar))
  20. {
  21. index++;
  22. }
  23.  
  24. new offset = index;
  25. new result[20];
  26. while ((index < length) && (string[index] > splitchar) && ((index - offset) < (sizeof(result) - 1)))
  27. {
  28. result[index - offset] = string[index];
  29. index++;
  30. }
  31. result[index - offset] = EOS;
  32. return result;
  33. }
  34.  
  35.  
  36. stock mktime(hour,minute,second,day,month,year) {
  37. new timestamp2;
  38.  
  39. timestamp2 = second + (minute * 60) + (hour * 3600);
  40.  
  41. new days_of_month[12];
  42.  
  43. if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) ) {
  44. days_of_month = {31,29,31,30,31,30,31,31,30,31,30,31}; // Schaltjahr
  45. } else {
  46. days_of_month = {31,28,31,30,31,30,31,31,30,31,30,31}; // keins
  47. }
  48. new days_this_year = 0;
  49. days_this_year = day;
  50. if(month > 1) { // No January Calculation, because its always the 0 past months
  51. for(new i=0; i<month-1;i++) {
  52. days_this_year += days_of_month[i];
  53. }
  54. }
  55. timestamp2 += days_this_year * 86400;
  56.  
  57. for(new j=1970;j<year;j++) {
  58. timestamp2 += 31536000;
  59. if ( ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0) ) timestamp2 += 86400; // Schaltjahr + 1 Tag
  60. }
  61.  
  62. return timestamp2;
  63. }
Add Comment
Please, Sign In to add comment