| | 1082 | # Parameter: Manufacturing year/week bytes |
| | 1083 | sub manufacture_date($$) |
| | 1084 | { |
| | 1085 | my ($year, $week) = @_; |
| | 1086 | |
| | 1087 | # In theory the year and week are in BCD format, but |
| | 1088 | # this is not always true in practice :( |
| | 1089 | if (($year & 0xf0) <= 0x90 && ($year & 0x0f) <= 0x09 |
| | 1090 | && ($week & 0xf0) <= 0x90 && ($week & 0x0f) <= 0x09) { |
| | 1091 | # Note that this heuristic will break in year 2080 |
| | 1092 | return sprintf("%d%02X-W%02X\n", |
| | 1093 | $year >= 0x80 ? 19 : 20, $year, $week); |
| | 1094 | } else { |
| | 1095 | return sprintf("0x%02X%02X\n", $year, $week); |
| | 1096 | } |
| | 1097 | } |
| | 1098 | |
| 1122 | | # In theory the year and week are in BCD format, but |
| 1123 | | # this is not always true in practice :( |
| 1124 | | if (($bytes->[93] & 0xf0) <= 0x90 |
| 1125 | | && ($bytes->[93] & 0x0f) <= 0x09 |
| 1126 | | && ($bytes->[94] & 0xf0) <= 0x90 |
| 1127 | | && ($bytes->[94] & 0x0f) <= 0x09) { |
| 1128 | | # Note that this heuristic will break in year 2080 |
| 1129 | | $temp = sprintf("%d%02X-W%02X\n", |
| 1130 | | $bytes->[93] >= 0x80 ? 19 : 20, |
| 1131 | | @{$bytes}[93..94]); |
| 1132 | | } else { |
| 1133 | | $temp = sprintf("0x%02X%02X\n", |
| 1134 | | @{$bytes}[93..94]); |
| 1135 | | } |
| 1136 | | printl $l, $temp; |
| | 1139 | printl $l, manufacture_date($bytes->[93], $bytes->[94]); |