diff --git a/Cargo.lock b/Cargo.lock index b9c79ce..df2c4d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -22,7 +22,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "daisy" -version = "0.1.1" +version = "0.1.2" dependencies = [ "cfg-if", "rug", diff --git a/Cargo.toml b/Cargo.toml index 4e9bbab..ba9715c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "daisy" -version = "0.1.1" +version = "0.1.2" edition = "2021" [profile.release] diff --git a/src/quantity/unit/mod.rs b/src/quantity/unit/mod.rs index d1e3bd7..e0d0d6e 100644 --- a/src/quantity/unit/mod.rs +++ b/src/quantity/unit/mod.rs @@ -44,6 +44,18 @@ pub enum UnitBase { GregorianYear, JulianYear, + // Volume + Liter, + USGallon, + Quart, + ImperialGallon, + Hogshead, + Cup, + Floz, + Pint, + Tablespoon, + Teaspoon, + // Pressure Pascal, Atmosphere, @@ -160,6 +172,50 @@ macro_rules! fromstring_db { (UnitBase::JulianYear, "julianYear"), (UnitBase::JulianYear, "julianYears"), + // Volume + (UnitBase::Liter, "liter"), + (UnitBase::Liter, "liters"), + (UnitBase::Liter, "litre"), + (UnitBase::Liter, "litres"), + (UnitBase::USGallon, "usgal"), + (UnitBase::USGallon, "gal"), + (UnitBase::USGallon, "gallon"), + (UnitBase::USGallon, "gallons"), + (UnitBase::Quart, "quart"), + (UnitBase::Quart, "quarts"), + (UnitBase::Quart, "qt"), + (UnitBase::ImperialGallon, "impgal"), + (UnitBase::ImperialGallon, "imperialGallon"), + (UnitBase::ImperialGallon, "imperialGallons"), + (UnitBase::Cup, "cup"), + (UnitBase::Floz, "floz"), + (UnitBase::Pint, "pint"), + (UnitBase::Pint, "pints"), + (UnitBase::Tablespoon, "tablespoon"), + (UnitBase::Tablespoon, "tablespoons"), + (UnitBase::Tablespoon, "tbsp"), + (UnitBase::Tablespoon, "Tbsp"), + (UnitBase::Teaspoon, "teaspoon"), + (UnitBase::Teaspoon, "teaspoons"), + (UnitBase::Teaspoon, "tsp"), + (UnitBase::Teaspoon, "Tsp"), + + + + (UnitBase::Hogshead, "hogshead"), + (UnitBase::Hogshead, "hogsheads"), + + + (UnitBase::Liter, "l", + ("Q","R","Y","Z","E","P","T","G","M","k","h","da","d","c","m","u","n","p","f","a","z","y","r","q") + ), + + (UnitBase::Liter, "L", + ("Q","R","Y","Z","E","P","T","G","M","k","h","da","d","c","m","u","n","p","f","a","z","y","r","q") + ), + + + // Pressure (UnitBase::Atmosphere, "atm"), (UnitBase::Atmosphere, "atmosphere"), @@ -361,6 +417,67 @@ macro_rules! unit_db { ), + // Volume + UnitBase::Liter => $X!( + UnitBase::Liter, "l", + rational, "0.001", + (UnitBase::Meter, 3f64) + ), + + UnitBase::Hogshead => $X!( + UnitBase::Hogshead, "hogshead", + rational, "0.2385", // 63 gallons + (UnitBase::Meter, 3f64) + ), + + UnitBase::USGallon => $X!( + UnitBase::USGallon, "gal", + rational, "0.003785411784", + (UnitBase::Meter, 3f64) + ), + + UnitBase::Quart => $X!( + UnitBase::Quart, "qt", + rational, "0.000946352946", + (UnitBase::Meter, 3f64) + ), + + UnitBase::ImperialGallon => $X!( + UnitBase::ImperialGallon, "impgal", + rational, "0.00454609", + (UnitBase::Meter, 3f64) + ), + + UnitBase::Cup => $X!( + UnitBase::Cup, "cup", + rational, "0.0002365882365", + (UnitBase::Meter, 3f64) + ), + + UnitBase::Floz => $X!( + UnitBase::Floz, "floz", + rational, "0.0000295735295625", + (UnitBase::Meter, 3f64) + ), + + UnitBase::Pint => $X!( + UnitBase::Pint, "pint", + rational, "0.00056826125", + (UnitBase::Meter, 3f64) + ), + + UnitBase::Tablespoon => $X!( + UnitBase::Tablespoon, "tbsp", + rational, "0.00001478676478125", + (UnitBase::Meter, 3f64) + ), + + UnitBase::Teaspoon => $X!( + UnitBase::Teaspoon, "tsp", + rational, "0.000005", + (UnitBase::Meter, 3f64) + ), + // Pressure diff --git a/units.md b/units.md index e94bde8..90050f2 100644 --- a/units.md +++ b/units.md @@ -1,3 +1,5 @@ +legal cup + | Unit | Syntax | |------------------------------------------------------------------------------|-----------------------------------------------------------------------------| | [Barn](https://en.wikipedia.org/wiki/Barn_(unit)) | `barn` | @@ -9,7 +11,6 @@ | [Byte](https://en.wikipedia.org/wiki/Byte) | `Bytes`, `bytes`, `Byte`, `byte`, `B`, `Octets`, `octets`, `Octet`, `octet` | | [Calorie](https://en.wikipedia.org/wiki/Calorie) | `calories`, `calorie`, `cal` | | [Coulomb](https://en.wikipedia.org/wiki/Coulomb) | `coulomb`, `C` | - | [Cup](https://en.wikipedia.org/wiki/Cup_(unit)) | `cups`, `cup` | | [DPI](https://en.wikipedia.org/wiki/Dots_per_inch) | `dpi` | | [Day](https://en.wikipedia.org/wiki/Day) | `days`, `day`, `d` | | [Degree](https://en.wikipedia.org/wiki/Degree_(angle)) | `degrees`, `degree`, `deg`, `°` | @@ -17,26 +18,21 @@ | [Electronvolt](https://en.wikipedia.org/wiki/Electronvolt) | `electronvolt`, `eV` | | [Euro](https://en.wikipedia.org/wiki/Euro) | `euros`, `euro`, `EUR`, `€` | | [Farad](https://en.wikipedia.org/wiki/Farad) | `farad`, `F` | - | [Fluid ounce](https://en.wikipedia.org/wiki/Fluid_ounce) | `fluidounces`, `fluidounce`, `floz` | | [Frame](https://en.wikipedia.org/wiki/Film_frame) | `frames`, `frame` | | [Frames per second](https://en.wikipedia.org/wiki/Frame_rate) | `fps` | - | [Gallon](https://en.wikipedia.org/wiki/Gallon) | `gallons`, `gallon`, `gal` | | [Gauss](https://en.wikipedia.org/wiki/Gauss_(unit)) | `gauss` | | [Gray](https://en.wikipedia.org/wiki/Gray_(unit)) | `gray`, `Gy` | | [Hectare](https://en.wikipedia.org/wiki/Hectare) | `hectare`, `ha` | | [Henry](https://en.wikipedia.org/wiki/Henry_(unit)) | `henrys`, `henries`, `henry`, `H` | | [Hertz](https://en.wikipedia.org/wiki/Hertz) | `hertz`, `Hz` | - | [Hogshead](https://en.wikipedia.org/wiki/Hogshead) | `hogsheads`, `hogshead` | | [Joule](https://en.wikipedia.org/wiki/Joule) | `joules`, `joule`, `J` | | [Katal](https://en.wikipedia.org/wiki/Katal) | `katal`, `kat` | | [Kelvin](https://en.wikipedia.org/wiki/Kelvin) | `kelvin`, `K` | | [Light-year](https://en.wikipedia.org/wiki/Light-year) | `lightyears`, `lightyear`, `ly` | - | [Liter](https://en.wikipedia.org/wiki/Liter) | `liters`, `liter`, `litres`, `litre`, `L`, `l` | | [Lumen](https://en.wikipedia.org/wiki/Lumen_(unit)) | `lumen`, `lm` | | [Lux](https://en.wikipedia.org/wiki/Lux) | `lux`, `lx` | | [Miles per hour](https://en.wikipedia.org/wiki/Miles_per_hour) | `mph` | | [Millimeter of mercury](https://en.wikipedia.org/wiki/Millimeter_of_mercury) | `mmHg` | - | [Mole](https://en.wikipedia.org/wiki/Mole_(unit)) | `mole`, `mol` | | [Newton](https://en.wikipedia.org/wiki/Newton_(unit)) | `newton`, `N` | | [Ohm](https://en.wikipedia.org/wiki/Ohm) | `ohms`, `ohm`, `Ω` | | [Ounce](https://en.wikipedia.org/wiki/Ounce) | `ounces`, `ounce`, `oz` | @@ -49,7 +45,6 @@ | [Percent](https://en.wikipedia.org/wiki/Parts-per_notation) | `percent`, `pct` | | [Person](https://en.wiktionary.org/wiki/person) | `persons`, `person`, `people` | | [Piece](https://en.wiktionary.org/wiki/piece) | `pieces`, `piece` | - | [Pint](https://en.wikipedia.org/wiki/Pint) | `pints`, `pint` | | [Pixel](https://en.wikipedia.org/wiki/Pixel) | `pixels`, `pixel`, `px` | | [Pound-force](https://en.wikipedia.org/wiki/Pound_%28force%29) | `pound_force`, `lbf` | | [Pound](https://en.wikipedia.org/wiki/Pound_(mass)) | `pounds`, `pound`, `lb` | @@ -58,8 +53,6 @@ | [Rod](https://en.wikipedia.org/wiki/Rod_(unit)) | `rods`, `rod` | | [Siemens](https://en.wikipedia.org/wiki/Siemens_(unit)) | `siemens`, `S` | | [Sievert](https://en.wikipedia.org/wiki/Sievert) | `sievert`, `Sv` | - | [Tablespoon](https://en.wikipedia.org/wiki/Tablespoon) | `tablespoons`, `tablespoon`, `tbsp` | - | [Teaspoon](https://en.wikipedia.org/wiki/Teaspoon) | `teaspoons`, `teaspoon`, `tsp` | | [Tesla](https://en.wikipedia.org/wiki/Tesla_(unit)) | `tesla`, `T` | | [Tonne](https://en.wikipedia.org/wiki/Tonne) | `tonnes`, `tonne`, `tons`, `ton`, `t` | | [US Dollar](https://en.wikipedia.org/wiki/USD) | `dollars`, `dollar`, `USD`, `$` |