2

単純なVIN(ISO 3779)デコーダーをコーディングしようとしています:メーカーとモデルイヤー。ただし、モデルイヤーのデコードに関していくつか問題があります。ウィキペディアによると:

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;厄介なハックを行う以外に、デコーダーを変更してこれを正しく行うにはどうすればよいですか?

4

1 に答える 1

1

位置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

そうは言っても、あなたの車は規則に従っていないようです。例外的なケースでは、コーディングの例外が必要です。これはハックではありません。ごめん。

于 2012-06-26T21:16:30.983 に答える