Skip to content

Commit

Permalink
Merge pull request #10 from NeedleInAJayStack/feature/quart
Browse files Browse the repository at this point in the history
Quart & Dry Volumes
  • Loading branch information
NeedleInAJayStack authored Apr 18, 2024
2 parents 79b843c + 338204b commit c63265c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 9 deletions.
6 changes: 5 additions & 1 deletion Sources/Units/Registry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,21 @@ internal class Registry {
DefaultUnits.deciliter,
DefaultUnits.kiloliter,
DefaultUnits.megaliter,
DefaultUnits.bushel,
DefaultUnits.teaspoon,
DefaultUnits.tablespoon,
DefaultUnits.fluidOunce,
DefaultUnits.cup,
DefaultUnits.pint,
DefaultUnits.gallon,
DefaultUnits.dryPint,
DefaultUnits.dryQuart,
DefaultUnits.peck,
DefaultUnits.bushel,
DefaultUnits.imperialFluidOunce,
DefaultUnits.imperialCup,
DefaultUnits.imperialPint,
DefaultUnits.imperialGallon,
DefaultUnits.imperialPeck,
DefaultUnits.metricCup,
]
}
53 changes: 46 additions & 7 deletions Sources/Units/Unit/DefaultUnits.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// Static type containing this package's pre-defined units
enum DefaultUnits {
// MARK: If adding additional units to this list, add corresponding entries in the `Unit+DefaultUnits.swift` file
// MARK: If adding units to this list, add corresponding entries in the `Unit+DefaultUnits.swift` & `Registry.swift` files

// MARK: Acceleration

Expand Down Expand Up @@ -986,12 +986,7 @@ enum DefaultUnits {
dimension: [.Length: 3],
coefficient: 1000
)
static let bushel = try! DefinedUnit(
name: "bushel",
symbol: "bushel",
dimension: [.Length: 3],
coefficient: 0.03523907
)
// Liquid measures
static let teaspoon = try! DefinedUnit(
name: "teaspoon",
symbol: "tsp",
Expand Down Expand Up @@ -1022,12 +1017,44 @@ enum DefaultUnits {
dimension: [.Length: 3],
coefficient: 473.176473e-6
)
static let quart = try! DefinedUnit(
name: "quart",
symbol: "qt",
dimension: [.Length: 3],
coefficient: 9.46352946e-4
)
static let gallon = try! DefinedUnit(
name: "gallon",
symbol: "gal",
dimension: [.Length: 3],
coefficient: 0.003785411784
)
// Dry measures: https://en.wikipedia.org/wiki/Dry_measure
static let dryPint: DefinedUnit = try! DefinedUnit(
name: "dryPint",
symbol: "drypt",
dimension: [.Length: 3],
coefficient: 5.506104713575e-4
)
static let dryQuart: DefinedUnit = try! DefinedUnit(
name: "dryQuart",
symbol: "dryqt",
dimension: [.Length: 3],
coefficient: 1.101220942715e-3
)
static let peck: DefinedUnit = try! DefinedUnit(
name: "peck",
symbol: "pk",
dimension: [.Length: 3],
coefficient: 8.80976754172e-3
)
static let bushel = try! DefinedUnit(
name: "bushel",
symbol: "bu",
dimension: [.Length: 3],
coefficient: 0.035239070167
)
// Imperial measures
static let imperialFluidOunce = try! DefinedUnit(
name: "imperialFluidOunce",
symbol: "ifl_oz",
Expand All @@ -1046,12 +1073,24 @@ enum DefaultUnits {
dimension: [.Length: 3],
coefficient: 568.26125e-6
)
static let imperialQuart = try! DefinedUnit(
name: "imperialQuart",
symbol: "iqt",
dimension: [.Length: 3],
coefficient: 1.1365225e-3
)
static let imperialGallon = try! DefinedUnit(
name: "imperialGallon",
symbol: "igal",
dimension: [.Length: 3],
coefficient: 0.00454609
)
static let imperialPeck: DefinedUnit = try! DefinedUnit(
name: "imperialPeck",
symbol: "ipk",
dimension: [.Length: 3],
coefficient: 9.09218e-3
)
static let metricCup = try! DefinedUnit(
name: "metricCup",
symbol: "mcup",
Expand Down
8 changes: 7 additions & 1 deletion Sources/Units/Unit/Unit+DefaultUnits.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,22 @@ public extension Unit {
static let deciliter = Unit(definedBy: DefaultUnits.deciliter)
static let kiloliter = Unit(definedBy: DefaultUnits.kiloliter)
static let megaliter = Unit(definedBy: DefaultUnits.megaliter)
static let bushel = Unit(definedBy: DefaultUnits.bushel)
static let teaspoon = Unit(definedBy: DefaultUnits.teaspoon)
static let tablespoon = Unit(definedBy: DefaultUnits.tablespoon)
static let fluidOunce = Unit(definedBy: DefaultUnits.fluidOunce)
static let cup = Unit(definedBy: DefaultUnits.cup)
static let pint = Unit(definedBy: DefaultUnits.pint)
static let quart = Unit(definedBy: DefaultUnits.quart)
static let gallon = Unit(definedBy: DefaultUnits.gallon)
static let dryPint = Unit(definedBy: DefaultUnits.dryPint)
static let dryQuart = Unit(definedBy: DefaultUnits.dryQuart)
static let peck = Unit(definedBy: DefaultUnits.peck)
static let bushel = Unit(definedBy: DefaultUnits.bushel)
static let imperialFluidOunce = Unit(definedBy: DefaultUnits.imperialFluidOunce)
static let imperialCup = Unit(definedBy: DefaultUnits.imperialCup)
static let imperialPint = Unit(definedBy: DefaultUnits.imperialPint)
static let imperialQuart = Unit(definedBy: DefaultUnits.imperialQuart)
static let imperialGallon = Unit(definedBy: DefaultUnits.imperialGallon)
static let imperialPeck = Unit(definedBy: DefaultUnits.imperialPeck)
static let metricCup = Unit(definedBy: DefaultUnits.metricCup)
}

0 comments on commit c63265c

Please sign in to comment.