uk-plate-age: how old is a GB number plate?
| (require uk-plate-age) | package: uk-plate-age |
This library reads the age identifier on a GB number plate and tells you the window in which the car was first registered. It has no dependencies beyond racket/base.
(require uk-plate-age) (issue-period->string (decode-plate "AB24 CDE")) ; "Mar 2024 - Aug 2024" (issue-period->string (decode-plate "XY74 ZZZ")) ; "Sep 2024 - Feb 2025" (issue-period->string (decode-plate "P123 ABC")) ; "Aug 1996 - Jul 1997" (decode-plate "ABZ 1234") ; #f, Northern Ireland plates carry no date (could-be-original? "AB74 CDE" 2019 5) ; #f, the plate is newer than the car
Install it with raco pkg install uk-plate-age and run the tests with raco test -p uk-plate-age.
1 How the age identifier works
There have been two formats since 1983, and the library handles both.
Current format, September 2001 onwards (AB24 CDE). The two digits change twice a year. In March they are the last two digits of the year, so 24 covers March to August 2024. In September, 50 is added, so 74 covers September 2024 to February 2025. The very first one was 51 in September 2001. 00 and 01 were never issued, so decode-plate returns #f for them.
Prefix format, August 1983 to August 2001 (P123 ABC). The first letter is the year. It changed every August, from A in 1983 up to R in 1997. From S in August 1998 the change moved to twice a year: T arrived in March 1999, then V, W, X and finally Y in March 2001. I, O, Q, U and Z were never used as year letters.
A quick way to get a feel for the system is to guess a few plates yourself. The CarCheckHQ plate year quiz shows you a plate and asks for the year, which is handy if you’re writing tests for code like this and want to sanity-check the edge cases (the 50 and 51 boundary, and S to Y in the prefix years).
2 Where a plate can mislead you
A private (cherished) plate can make a car look older than it is, never newer. If the plate’s window starts after the car was first registered, something is off, and could-be-original? returns #f.
Northern Ireland plates (ABZ 1234) and pre-1983 dateless plates have no age identifier at all.
Q plates mean the vehicle’s age or identity couldn’t be confirmed (kit cars, some imports, rebuilt vehicles), so they aren’t decoded.
A plate only tells you when the car was first registered in GB. An import can be years older than its plate. If you’re buying, compare the plate with the logbook and the MOT history rather than trusting the plate alone. The official rules are on the GOV.UK page on Q registration numbers and the vehicle registration guide. On the logbook side, CarCheckHQ has a plain-English piece on whether a V5C proves who owns a car (short answer: no, it shows the registered keeper).
3 API
struct
(struct issue-period ( from-year from-month to-year to-month format) #:extra-constructor-name make-issue-period) from-year : exact-integer? from-month : (integer-in 1 12) to-year : exact-integer? to-month : (integer-in 1 12) format : (or/c 'current 'prefix)
procedure
(normalise-plate plate) → string?
plate : string?
procedure
(decode-plate plate) → (or/c issue-period? #f)
plate : string?
procedure
(issue-period->string d) → string?
d : issue-period?
procedure
(could-be-original? plate year month) → boolean?
plate : string? year : exact-integer? month : (integer-in 1 12)
4 Licence
MIT. Written and maintained by CarCheckHQ, a UK used-car check service run by DESKLINK LTD (registered in England and Wales, company number 17076467). Corrections are welcome as issues on the source repository.