我正在尝试编写一个简单的VIN (ISO 3779)解码器:制造商和型号年。不过,我在解码模型年时遇到了一些问题。根据Wikipedia的说法
For passenger cars, and for multipurpose passenger vehicles and trucks with a gross vehicle weight rating of 10,000 lb (4,500 kg) or less, if position 7 is numeric, the model year in position 10 of the VIN refers to a year in the range 1980–2009. If position 7 is alphabetic, the model year in position 10 of VIN refers to a year in the range 2010–2039.
我的车的VIN (2012车型)有以下信息:
VSS---1--C-------
12345678901234567制造商: SEAT,型号年份: 1982 (一些在线VIN解码器给我1982,另一些给我2012)
我怎么才能修改我的解码器,使我得到正确的,而不是做一个讨厌的if (Manufacturer == "SEAT") Year += 30;黑客?
发布于 2012-06-27 05:16:31
在阅读了位置7和10之后,下面是一些PHP代码:
$year = date_1980_2009( $position_10 ); # use your current date function...
if ( preg_match( "/^[A-Z]$/i", $position_7 ) ) $year += 30; # add 30 years if 7 is alphabetic话虽如此,你的车似乎没有遵守规则。异常情况需要编码异常--这不是hack。抱歉的。
https://stackoverflow.com/questions/11215819
复制相似问题