Coles Barcode Generator

My local Coles supermarket offers the following deal. Free, 90-minute parking in the shopping mall parking lot when you spend $30 or more at Coles.

The method in which they validate this is via a barcode printed on the receipt which you must scan at the parking fee payment machine. The barcode is the same for each customer but changes every day.

The barcode content is very simple, it's a CODE-128 of 88YYMMDD, where the YYMMDD represents tomorrow's date. For example, the code 88231115 would work for Tuesday 14th November, 2023.

I used to have this generated using Node-RED and have it sent via a Telegram bot. I now just generate the code within the browser, it's a single static HTML file plus a JavaScript library. The application can be viewed here.

The code to generate the barcode is as follows:

let date = new Date();
date.setDate(date.getDate() + 1);
date.setMinutes(date.getMinutes() - date.getTimezoneOffset());
let dateString = date.toISOString();
JsBarcode("#barcode", "88" + [2, 3, 5, 6, 8, 9].map(i => dateString[i]).join(""));