Constructor.
Optional
monthRange: IntRangethe month range (1-12, inclusive)
Optional
dayOfMonthRange: IntRangethe day of month range (1-31, inclusive)
Optional
dayOfWeekRange: IntRangethe day of week range (1-7, with 1 = Monday, 7 = Sunday, inclusive)
Optional
minuteOfDayRange: IntRangethe minute of day range (0-1440, inclusive minimum, exclusive maximum)
Optional
rates: TariffRate[]the rates, as an array of TariffRate
objects
Private
Optional
#dayPrivate
Optional
#dayPrivate
Optional
#minutePrivate
Optional
#monthPrivate
#ratesGet the rates, as an object of rate ID to TariffRate
objects.
Static
ALL_Static
ALL_Static
ALL_Static
ALL_Private
#datePrivate
#datePrivate
#rangeTest if an optional range contains a value.
the number to test if the range contains
Optional
range: IntRangethe range to test
Optional
exclusiveEnd: booleanif true
then treat the range end as an exclusive bound
true
if the given range is not defined, or it contains the given value
Test if this tariff applies on a given date.
All range constraints are treated as inclusive bounds, except for
the minuteOfDayRange
that is treated as an inclusive minimum and
exclusive maximum.
the date to test if this rate applies at
Optional
utc: booleanif true
then use UTC date components, otherwise assume the local time zone
true
if this tariff applies on the given date
Compares this object with the specified object for order.
Unbounded (null
) values are ordered before bounded (non-null
) values.
the tariff to compare to
-1
, 0
, or 1
if this is less than, equal to, or greater than o
Protected
componentsGet a string representation of the components of this description.
string representation of the components of this tariff
The toString() method will call this to generate a string representation of this tariff. Extending classes can override this method (possibly invoking this implementation to pick up the components rendered by this class).
Format a field range into a locale-specific string.
the desired locale
the field to format
Optional
options: TemporalRangesTariffFormatOptionsthe formatting options
the formatted field range value
TypeError
if field
is not supported
Get a string representation.
the string representation
This method will call the componentsDescription() method to generate a string representation of this tariff.
Static
formatFormat a field range value into a locale-specific string.
the desired locale
the field to format
Optional
value: IntRangethe field value to format; if undefined then "all possible values" will be assumed
Optional
options: TemporalRangesTariffFormatOptionsthe options
the formatted field range value
TypeError
if field
is not supported
Static
parseParse time range criteria into a TemporalRangesTariff
instance.
the locale to parse the ranges as
Optional
monthRange: stringthe month range to parse, for example January-December
, Jan-Dec
, or 1-12
Optional
dayOfMonthRange: stringthe day of month range to parse, for example 1-31
Optional
dayOfWeekRange: stringthe day of week range to parse, for example Monday-Sunday
, Mon-Sun
, or 1-7
Optional
minuteOfDayRange: stringthe minute of day range to parse, for example 00:00-24:00
or 0-24
Optional
rates: TariffRate[]the tariff rates to associate with the time range criteria
Optional
options: TemporalRangesTariffFormatOptionsthe formatting options to use
the new instance
Note that the minuteOfDayRange
can be specified as a range of HH:MM
24-hour hour and minute
values, or whole hours. For example 01:00-08:00
and 1-8
are equivalent.
Additionally, all range values may be specified as *
to mean "all possible values", in which
that range will be resolved to undefined
.
Generated using TypeDoc
A tariff with time-based range rules.
The rules associated with this tariff are represented by a set of date ranges that serve as the constraints that must be satisfied by a given date for the rule to apply.
Remarks
The date range constraints use inclusive minimum/maximum matching semantics, except for the
minuteOfDayRange
constraint, that uses inclusive minimum and exclusive maximum semantics.The time-based constraints supported are:
Example
The parse() method provides an easy way to parse instances from language-specific time range values: