Home > nifty-tou > ChronoTariff
A chronologically-based tariff, such as a "daily" charge.
Signature:
export default class ChronoTariff
Constructor | Modifiers | Description |
---|---|---|
(constructor)(chronoUnit, rate, name) | Constructor. |
Property | Modifiers | Type | Description |
---|---|---|---|
name | readonly |
string | undefined | Get the optional name. |
rate | readonly |
number | Get the rate. |
unit | readonly |
ChronoTariffUnit | Get the unit. |
Method | Modifiers | Description |
---|---|---|
quantity(from, to, utc) | Calcualte the count of units between two dates. The cost of this tariff can be calculated by multiplying the |
const tariff = new ChronoTariff(ChronoTariffUnit.DAYS, 10);
tariff.rate * tariff.quantity(
new Date('2024-01-01T00:00:00Z'),
new Date('2024-01-08T00:00:00Z'),
true) === 70; // 7 days @ 10/day
|