Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function timeDecoder($time) {
- if($time != "0000") {
- if(strlen($time) == 4) {
- $time = "0000".$time;
- $ct_or_at = 1;
- }
- $time = strtolower($time);
- $monarr = array('2' => ['01', '09', 0],
- '3' => ['01', '09', 16],
- '4' => ['02', '10', 0],
- '5' => ['02', '10', 16],
- '6' => ['03', '11', 0],
- '7' => ['03', '11', 16],
- '8' => ['04', '12', 0],
- '9' => ['04', '12', 16],
- 'a' => ['05', '', 0],
- 'b' => ['05', '', 16],
- 'c' => ['06', '', 0],
- 'd' => ['06', '', 16],
- 'e' => ['07', '', 0],
- 'f' => ['07', '', 16],
- '0' => ['', '08', 0],
- '1' => ['08', '', 16],
- );
- $hex = array('a' => 10, 'b' => 11, 'c' => 12, 'd' => 13, 'e' => 14, 'f' => 15);
- $mins = array('a' => 16, 'b' => 24, 'c' => 32, 'd' => 40, 'e' => 48, 'f' => 56);
- $month = substr($time,4,1);
- $day = substr($time,5,1);
- $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));
- if(is_numeric(substr($time,7,1))) {
- $par = substr($time,7,1) % 2 == 0 ? 0 : 1;
- } else {
- $par = $hex[substr($time,7,1)] % 2 == 0 ? 0 : 1;
- }
- if(is_numeric(substr($time, 2,1))) {
- $hr = substr($time, 2,1) * 2;
- } else {
- $hr = $hex[substr($time,2,1)] * 2;
- }
- if(is_numeric(substr($time, 3,1))) {
- $min = substr($time,3,1) * 8;
- } else {
- $min = $mins[substr($time,3,1)];
- $hr++;
- }
- if(is_numeric(substr($time, 0,1))) {
- $min += floor(substr($time,0,1) / 2);
- } else {
- $min += floor($hex[substr($time,0,1)] / 2);
- }
- if(strlen($min) == 1) {
- $min = "0" . $min;
- }
- if(isset($ct_or_at)) {
- $time = "<font style='color: red'>" . $year . "-" . $monarr[$month][$par] . "-" . (is_numeric($day) ? $monarr[$month][2] + $day : $monarr[$month][2] + $hex[$day]) . "</font>";
- return $time;
- } else {
- $time = $year . "-" . $monarr[$month][$par] . "-" . (is_numeric($day) ? $monarr[$month][2] + $day : $monarr[$month][2] + $hex[$day]) . " " . $hr . ":" . $min;
- return $time;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement