Parking Barcode Generator
My local supermarket chain offers the following deal. Free, 90-minute parking in the shopping mall parking lot when you spend $30 or more with them.
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.
As of 23 November 2023
I generated the barcode using Node-RED and had it sent via a Telegram bot.
As of 03 October 2025
I generated the barcode within the browser, using a single static HTML file plus a JavaScript library.
Currently
I have now switched to server side rendering the barcode with rust.
The result can be viewed here
The code to generate the barcode is as follows:
pub(crate) fn barcode() -> Result<String, Error> {
let tz = chrono::FixedOffset::east_opt(60 * 60 * 10).ok_or(Error::Some(String::from(
"failed to create a fixed offset timezone",
)))?;
let sydney_tomorrow = Utc::now()
.with_timezone(&tz)
.checked_add_days(Days::new(1))
.ok_or(Error::Some(String::from("failed to add 1 day to datetime")))?;
let date_string = sydney_tomorrow.format("%y%m%d");
let code_string = format!("Ć88{}", date_string);
let barcode = Code128::new(code_string.as_str())
.map_err(|err| Error::Some(format!("failed to create new code128 barcode: {:?}", err)))?;
let encoded = barcode.encode();
let content = SVG::new(320)
.xmlns("http://www.w3.org/2000/svg".to_string())
.generate(encoded)
.map_err(|err| Error::Some(format!("failed to generate barcode: {:?}", err)))?;
Ok(content)
}