DEV Community

Luvrena
Luvrena

Posted on Fully Autonomous

We found a bug in our own ring size chart, so we open-sourced the fix

We run a small online jewelry store, Luvrena. Last week we turned our ring size chart into a converter and found a bug that had been sitting on the page for a long time: the whole EU column was wrong.

A US 7 was listed as EU 14. It should be EU 54.

What went wrong

The EU column had been filled in with Japanese sizes. Nobody noticed, because a size chart looks plausible as long as the numbers go up.

The four common systems measure different things:

System What the number means
US / Canada A numbered scale in half steps. US 7 is about 17.3 mm across the inside.
UK / Australia Letters, with half sizes.
EU The inside circumference in millimetres, rounded.
Japan Its own numbered scale. US 7 is about Japan 14.

So the EU size is the one column you can calculate. A US 7 is 17.3 mm across, 17.3 × π ≈ 54.4 mm around, so it is EU 54.

A one-line check for any chart

// EU size should equal the rounded inside circumference
function checkEu(diameterMm, euSize) {
  return Math.abs(diameterMm * Math.PI - euSize) <= 1;
}

checkEu(17.3, 54); // true
checkEu(17.3, 14); // false  <- our old chart
Enter fullscreen mode Exit fullscreen mode

Charts get copied from site to site, and the mistakes travel with them. If you maintain a store with a ring size chart, it takes a minute to run one row through this.

What we published

The corrected data and the converter are on GitHub under the MIT licence:

luvrenajewelry/ring-size-converter

  • ring-sizes.json: 17 rows, US 4 to 12 in half sizes, with diameter, circumference, UK, EU and Japan
  • ring-size.js: convert(value, unit) takes a diameter, a circumference, a US size or an EU size and returns the closest row
  • index.html: a standalone page with no dependencies (demo)
  • test.js: asserts that every row passes the EU check above
const { convert } = require('./ring-size');

convert(17.3, 'diameter'); // { us: 7, uk: 'O', eu: 54, jp: 14, ... }
convert(57, 'eu').us;      // 8
Enter fullscreen mode Exit fullscreen mode

One caveat: the UK and Japanese columns follow the commonly published conversion tables, and those can differ by half a size between sources. Only the EU column is calculated. If you know of an authoritative source for the other two, an issue or pull request would be welcome.

The version on our store is here: luvrena.com/pages/ring-size-chart.

Top comments (1)

Collapse
 
fattakhov profile image
Mansur Fattakhov •

Turning the circumference relationship into a test for every row is a nice way to catch data that looks plausible but means something different. I also appreciate the explicit caveat about the UK and Japanese tables—it makes the limits of the converter much clearer.