Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: George Lemon <georgelemon@protonmail.com>
  • Loading branch information
georgelemon committed Aug 26, 2023
1 parent 0ca1c30 commit acb014b
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,54 @@
<img src="https://github.com/supranim/money/workflows/test/badge.svg" alt="Github Actions"> <img src="https://github.com/supranim/money/workflows/docs/badge.svg" alt="Github Actions">
</p>

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)
Expand Down

0 comments on commit acb014b

Please sign in to comment.