createAmountIn

createAmountIn(T)(T t, double amount): template function returns Amount

createAmountIn
(
T
)
(
T t
,
double amount
)

Examples

auto GBP = new Currency("GBP", "Great British Pound", 2);
import vibe.core.log: logInfo;
logInfo("" ~ GBP.symbol ~ " - " ~ GBP.name ~ "");
auto amount = createAmountIn!Currency(GBP, 1000);
logInfo(amount.id.to!string);
logInfo(amount.symbol.to!string);
logInfo(amount.amount.to!string);
auto ts = cast(DateTime) amount.timestamp;
logInfo(ts.toISOExtString());


assert(is(typeof(GBP) == Currency));
assert(is(typeof(amount) == Amount));

createMoneyIn (T)(T t)

template function returns currency
alias GBP = currency!("GBP");
// auto a = createAmountIn!Currency(GBP, 1000);
// auto money = createMoneyIn!Amount(a);
logInfo(format("%.2f", GBP(1000)+GBP(2341.64)));
// assert(is(typeof(money) == currency));
// assert(is(typeof(a) == Amount));
// assert(is(typeof(GBP) == currency));

Meta