Function timeInterval

  • Constructs a new custom interval given the specified floor and offset functions.

    The returned custom interval is not countable, i.e. does not expose the methods "count(..)" and "every(...)".

    Parameters

    • floor: ((date) => void)

      A floor function which takes a single date as an argument and rounds it down to the nearest interval boundary.

        • (date): void
        • Parameters

          Returns void

    • offset: ((date, step) => void)

      An offset function which takes a date and an integer step as arguments and advances the specified date by the specified number of boundaries; the step may be positive, negative or zero.

        • (date, step): void
        • Parameters

          • date: Date
          • step: number

          Returns void

    Returns TimeInterval

  • Constructs a new custom interval given the specified floor, offset and count functions.

    The returned custom interval is countable and exposes the methods "count(..)" and "every(...)".

    Note: due to an internal optimization, the specified count function must not invoke interval.count on other time intervals.

    Parameters

    • floor: ((date) => void)

      A floor function which takes a single date as an argument and rounds it down to the nearest interval boundary.

        • (date): void
        • Parameters

          Returns void

    • offset: ((date, step) => void)

      An offset function which takes a date and an integer step as arguments and advances the specified date by the specified number of boundaries; the step may be positive, negative or zero.

        • (date, step): void
        • Parameters

          • date: Date
          • step: number

          Returns void

    • count: ((start, end) => number)

      A count function which takes a start date and an end date, already floored to the current interval, and returns the number of boundaries between the start (exclusive) and end (inclusive). Note: due to an internal optimization, the specified count function must not invoke interval.count on other time intervals.

        • (start, end): number
        • Parameters

          Returns number

    • Optional field: ((date) => number)

      An optional field function which takes a date, already floored to the current interval, and returns the field value of the specified date, corresponding to the number of boundaries between this date (exclusive) and the latest previous parent boundary. For example, for the timeDay interval, this returns the number of days since the start of the month. If a field function is not specified, it defaults to counting the number of interval boundaries since the UNIX epoch of January 1, 1970 UTC. The field function defines the behavior of interval.every.

        • (date): number
        • Parameters

          Returns number

    Returns CountableTimeInterval