Mathjs: US and metric cooking units

Created on 21 Mar 2019  路  5Comments  路  Source: josdejong/mathjs

Some units are in metric while others are in US units. For example:
math.unit(1,"cup").toNumber("tablespoon")
15.772546666666665
From here, a US legal cup is 240 mL, while a US customary cup is 236.5882365 mL.
From here, a metric tablespoon is 15 mL, while a US tablespoon is approximately 14.8 mL.
From my example, it seems like it uses a US customary cup and a metric tablespoon.
Please include the option for US units.

feature help wanted

All 5 comments

Hm yes you're right, we should change the value of tablespoon to ~14.8 mL to make it consistent with cup. And probably create new units for the other variants of the units.

Here is a list of the United States Customary Units.

Who's interested in fixing the these units?

It will be a breaking change so we'll have to schedule it for v6

I haven't found anything that solves the US system, Imperial, Metric differences of cup, Tbs etc well, same issue happens in measuring-cup. The need of

  1. Transform between systems (US, Imperial, Metric, etc)
  2. Transform between units (cup of sugar -> g of sugar)

Are very common use cases for cooking, (the 2nd point is a total different issue, but would be amazing to have something to do it)

I've been working (very slowly) on migrating all the units functions from math.js into their own library. Would you mind raising this issue over at https://github.com/ericman314/UnitMath/issues ? That way I will not forget about it. I imagine that this might be something we could address with a configuration option to choose between the various types of cups, etc, or have units with suffixes such as cupImperial, with an alias of cup, depending on the configuration option.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lwirtz picture lwirtz  路  3Comments

gnobre picture gnobre  路  4Comments

smith120bh picture smith120bh  路  4Comments

zcohan picture zcohan  路  4Comments

piotr-s-brainhub picture piotr-s-brainhub  路  3Comments