From acb014bddce9000b30acbdeca3e57d6c982aecde Mon Sep 17 00:00:00 2001 From: George Lemon Date: Sat, 26 Aug 2023 12:09:29 +0300 Subject: [PATCH] update Signed-off-by: George Lemon --- README.md | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 82914c7..424569b 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,54 @@ Github Actions Github Actions

+Nim library to make working with money safer, easier and fun! +> If I had a dime for every time I've seen someone use FLOAT to store currency, I'd have $999.997634 -- Bill Karwin + +This library is inspired from [moneyphp/money](https://github.com/moneyphp/money). + ## 😍 Key Features - Framework agnostic +- Works with BigInts via `pkg/bigints` +- Math Operations `+`, `-`, `*`, `/` +- Math Operations (mutable) `+=` `-=`, `*=`, `*/` => `add`, `sub`, `multi`, `div` +- Money Formatting (including intl formatter) +- Money Exchange using 3rd party providers ## Examples -... -## Todo -Use `bigints` instead +Use `defaultCurrency` option to change the default currency at compile-time. Example `-d:defaultCurrency:49` (default) for `EURO` + +```nim +import money + +assert $(fmt("150")) == "EUR 1.50" +assert 2500.EUR == fmt"2500" # EUR 25.50 +``` + +### Math + +```nim +var + x = amount("150", EUR) + y = amount("150", EUR) + +assert x + y == 300.EUR # EUR 3.00 + +x += y +assert x == 300.EUR # EUR 3.00 +assert x + y > y # EUR 3.00 > EUR 1.50 +``` + +### Comparisons +Comparing `x` to `y` is easy! + +```nim +var x = newMoney("100") # EUR 1.00 +var y = newMoney("150") # EUR 1.50 + +assert x <= y +assert fmt("2500") <= fmt("2590") # 25.00 <= 25.90 +``` ### ❤ Contributions & Support - 🐛 Found a bug? [Create a new Issue](https://github.com/supranim/money/issues)