Add support for Imperial Units (oz, lb) #1

Closed
opened 2025-12-28 22:10:14 +01:00 by Ghost · 2 comments
Ghost commented 2025-12-28 22:10:14 +01:00 (Migrated from codeberg.org)

Gram only works with metric units; support for imperial units could be useful.

Currently supported units :
kg, g, mg, l (liter), dl, cl, ml

Gram only works with metric units; support for imperial units could be useful. Currently supported units : kg, g, mg, l (liter), dl, cl, ml
Ghost commented 2025-12-29 00:17:33 +01:00 (Migrated from codeberg.org)

Hey! I've submitted a pull request (#2 ) to add more units :D both American imperial and some UK units as well!

Most of the changes are to the UNIT_CONVERSION constant but I also added my own tests for my code!

Let me know if any more changes are needed or if their are any issues!

Hey! I've submitted a pull request (#2 ) to add more units :D both American imperial and some UK units as well! Most of the changes are to the UNIT_CONVERSION constant but I also added my own tests for my code! Let me know if any more changes are needed or if their are any issues!
Ghost commented 2025-12-30 21:42:56 +01:00 (Migrated from codeberg.org)

Thanks! I think that for recipes, a simple conversion between volumes and weights/masses won't be enough, as a volume of water ≠ a volume of flour. I believe the implementation will require precise management of ingredients and their volume-to-weight ratios. We'll have to see whether this should be integrated directly into the parser or handled as an external function. I'm continuing to explore the matter !

Thanks! I think that for recipes, a simple conversion between volumes and weights/masses won't be enough, as a volume of water ≠ a volume of flour. I believe the implementation will require precise management of ingredients and their volume-to-weight ratios. We'll have to see whether this should be integrated directly into the parser or handled as an external function. I'm continuing to explore the matter !
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gram-lang/gram#1
No description provided.