Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. function timeDecoder($time) {
  2. if($time != "0000") {
  3. if(strlen($time) == 4) {
  4. $time = "0000".$time;
  5. $ct_or_at = 1;
  6. }
  7. $time = strtolower($time);
  8. $monarr = array('2' => ['01', '09', 0],
  9. '3' => ['01', '09', 16],
  10. '4' => ['02', '10', 0],
  11. '5' => ['02', '10', 16],
  12. '6' => ['03', '11', 0],
  13. '7' => ['03', '11', 16],
  14. '8' => ['04', '12', 0],
  15. '9' => ['04', '12', 16],
  16. 'a' => ['05', '', 0],
  17. 'b' => ['05', '', 16],
  18. 'c' => ['06', '', 0],
  19. 'd' => ['06', '', 16],
  20. 'e' => ['07', '', 0],
  21. 'f' => ['07', '', 16],
  22. '0' => ['', '08', 0],
  23. '1' => ['08', '', 16],
  24. );
  25. $hex = array('a' => 10, 'b' => 11, 'c' => 12, 'd' => 13, 'e' => 14, 'f' => 15);
  26. $mins = array('a' => 16, 'b' => 24, 'c' => 32, 'd' => 40, 'e' => 48, 'f' => 56);
  27. $month = substr($time,4,1);
  28. $day = substr($time,5,1);
  29. $year = 1980 + substr($time,6,1) * 8 + (is_numeric(substr($time,7,1)) ? floor(substr($time,7,1) / 2) : floor($hex[substr($time,7,1)] / 2));
  30. if(is_numeric(substr($time,7,1))) {
  31. $par = substr($time,7,1) % 2 == 0 ? 0 : 1;
  32. } else {
  33. $par = $hex[substr($time,7,1)] % 2 == 0 ? 0 : 1;
  34. }
  35. if(is_numeric(substr($time, 2,1))) {
  36. $hr = substr($time, 2,1) * 2;
  37. } else {
  38. $hr = $hex[substr($time,2,1)] * 2;
  39. }
  40. if(is_numeric(substr($time, 3,1))) {
  41. $min = substr($time,3,1) * 8;
  42. } else {
  43. $min = $mins[substr($time,3,1)];
  44. $hr++;
  45. }
  46. if(is_numeric(substr($time, 0,1))) {
  47. $min += floor(substr($time,0,1) / 2);
  48. } else {
  49. $min += floor($hex[substr($time,0,1)] / 2);
  50. }
  51. if(strlen($min) == 1) {
  52. $min = "0" . $min;
  53. }
  54. if(isset($ct_or_at)) {
  55. $time = "<font style='color: red'>" . $year . "-" . $monarr[$month][$par] . "-" . (is_numeric($day) ? $monarr[$month][2] + $day : $monarr[$month][2] + $hex[$day]) . "</font>";
  56. return $time;
  57. } else {
  58. $time = $year . "-" . $monarr[$month][$par] . "-" . (is_numeric($day) ? $monarr[$month][2] + $day : $monarr[$month][2] + $hex[$day]) . " " . $hr . ":" . $min;
  59. return $time;
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement