Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
generated fromsupranim/temple

Create, calculate and format money in Nim language (WIP)

License

NotificationsYou must be signed in to change notification settings

openpeeps/money

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Create, calculate and format money in 👑 Nim language.

nimble install money

API reference
Github ActionsGithub 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

😍 Key Features

  • Framework agnostic
  • Works with BigInts viapkg/bigints
  • Math Operations+,-,*,/
  • Math Operations (mutable)+=-=,*=,/= =>add,sub,multi,div
  • Money Formatting (including intl formatter)
  • Money Exchange using 3rd party providers

Examples

UsedefaultCurrency option to change the default currency at compile-time. Example-d:defaultCurrency:49 (default) forEURO

import moneyassert$(fmt("150"))=="EUR 1.50"assert2500.EUR== fmt"2500"# EUR 25.50

Math

var  x=amount("150",EUR)  y=amount("150",EUR)assert x+ y==300.EUR# EUR 3.00x+= yassert x==300.EUR# EUR 3.00assert x+ y> y# EUR 3.00 > EUR 1.50
var x=fmt("100")assert$(x-fmt(50))=="EUR 0.50"

Comparisons

Comparingx toy is easy!

var  x=100.EUR  y=150.EURassert x==100.EURassert x< yassert x>=99.EURassert x!=100.USDassert y> xassert y>=149.EUR

Cart Example

Dummy cart example available in/tests

❤ Contributions & Support

This library is inspired frommoneyphp/money.

🎩 License

Money | MIT license.Made by Humans from OpenPeeps for Supranim
Copyright © 2023 Supranim | OpenPeeps & Contributors — All rights reserved.

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp