Class YearTemporalRangesTariff

An extension of TemporalRangesTariff with support for an additional year range constraint.

Hierarchy

Constructors

Properties

#dayOfMonthRange?: IntRange
#dayOfWeekRange?: IntRange
#minuteOfDayRange?: IntRange
#monthRange?: IntRange
#rates: Record<string, TariffRate>
#yearRange?: IntRange

Accessors

  • get ALL_MINUTES_OF_DAY(): IntRange
  • Range for all minutes of a day: 0 - 1440 (inclusive min, exclusive max).

    Returns IntRange

Methods

  • Translate a Date day value into a range between 1..7.

    Parameters

    • value: number

      the Date day value to translate

    Returns number

    the day-of-week value with Monday == 1, Sunday == 7

  • Translate a Date month value into a range between 1..12.

    Parameters

    • value: number

      the Date month value to translate

    Returns number

    the month value with January == 1, December == 12

  • Test if an optional range contains a value.

    Parameters

    • value: number

      the number to test if the range contains

    • Optional range: IntRange

      the range to test

    • Optional exclusiveEnd: boolean

      if true then treat the range end as an exclusive bound

    Returns boolean

    true if the given range is not defined, or it contains the given value

  • Test if an optional year range contains a value.

    Parameters

    • value: number

      the number to test if the range contains

    • Optional range: IntRange

      the range to test

    Returns boolean

    true if the given range is not defined, or it contains the given value

  • Test if an optional year range contains a value, with the range maximum treated as unbounded.

    Parameters

    • value: number

      the number to test if the range contains

    • Optional range: IntRange

      the range to test

    Returns boolean

    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.

    Parameters

    • date: Date

      the date to test if this rate applies at

    • Optional utc: boolean

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

    Returns boolean

    true if this tariff applies on the given date

  • 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.

    Parameters

    • date: Date

      the date to test if this rate applies at

    • Optional utc: boolean

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

    Returns boolean

    true if this tariff applies on the given date

  • Parse time range criteria into a TemporalRangesTariff instance.

    Parameters

    • locale: string

      the locale to parse the ranges as

    • Optional monthRange: string

      the month range to parse, for example January-December, Jan-Dec, or 1-12

    • Optional dayOfMonthRange: string

      the day of month range to parse, for example 1-31

    • Optional dayOfWeekRange: string

      the day of week range to parse, for example Monday-Sunday, Mon-Sun, or 1-7

    • Optional minuteOfDayRange: string

      the 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: TemporalRangesTariffFormatOptions

      the formatting options to use

    Returns TemporalRangesTariff

    the new instance

    Remarks

    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.

  • Parse time range criteria into a YearTemporalRangesTariff instance.

    Parameters

    • locale: string

      the locale to parse the ranges as

    • Optional yearRange: string

      the year range to parse, for example 2000-2023

    • Optional monthRange: string

      the month range to parse, for example January-December, Jan-Dec, or 1-12

    • Optional dayOfMonthRange: string

      the day of month range to parse, for example 1-31

    • Optional dayOfWeekRange: string

      the day of week range to parse, for example Monday-Sunday, Mon-Sun, or 1-7

    • Optional minuteOfDayRange: string

      the 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: TemporalRangesTariffFormatOptions

      the formatting options

    Returns YearTemporalRangesTariff

    the new instance

    Remarks

    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