Class YearTemporalRangesTariffSchedule<T, O>

A schedule, or collection, of YearTemporalRangesTariff rules that supports resolving rates for dates.

Remarks

By default this schedule works similarly to the TemporalRangesTariffSchedule, except using YearTemporalRangesTariff instances that include a year criteria for matching dates. The yearExtend option changes the matching to treat the "most recent" year rules as having unbounded maximum values. The idea here is that the most recently defined rules remain applicable into future years, until another set of rules for some future year overrides them.

Type Parameters

Hierarchy

Constructors

Properties

#options: undefined | O
#rules: readonly T[]

Accessors

  • get multipleMatch(): boolean
  • Get the multiple-match mode.

    Returns boolean

Methods

  • Find the rules that apply on a given date.

    Parameters

    • date: Date

      the date to find the matching rules at

    • first: boolean

      true to return the first match, false to return all matches

    • yearExtend: boolean

      true to extend the most recent available year

    • Optional utc: boolean

      if true then use UTC date components, otherwise assume the local time zone

    Returns T[]

    the list of matching rules

  • Find the rules that apply on a given date.

    Parameters

    • date: Date

      the date to find the matching rules at

    • first: boolean

      true to return the first match, false to return all matches

    • Optional utc: boolean

      if true then use UTC date components, otherwise assume the local time zone

    Returns T[]

    the list of matching rules

  • Find the first rule that applies on a given date.

    Parameters

    • date: Date

      the date to find the first matching rule at

    • Optional utc: boolean

      if true then use UTC date components, otherwise assume the local time zone

    Returns undefined | T

    the first available matching rule, or undefined if no rules match

  • Find the rules that apply on a given date, repsecting the multipleMatch property.

    Parameters

    • date: Date

      the date to find the matching rules at

    • Optional utc: boolean

      if true then use UTC date components, otherwise assume the local time zone

    Returns T[]

    the list of matching rules; at most one if multipleMatch is false

  • Resolve the tariff rates that apply on a given date, respecting the multipleMatch property.

    Duplicate rate id values will override existing rates, so that the last-seen rate for a given id is the one returned.

    Parameters

    • date: Date

      the date to resolve

    • Optional utc: boolean

      if true then use UTC date components, otherwise assume the local time zone

    Returns Record<string, TariffRate>

    all tariff rates tha apply on the given date, as a Record of rate id values to associated rate instances

Generated using TypeDoc