@geogirafe/lib-geoportal
    Preparing search index...

    A class for formatting date and time values based on an ITimeOption object. Provides utility functions for parsing dates and date ranges, validating them, and generating formatted query strings for temporal layer filtering.

    The class allows customized configurations through its constructor options, including setting minimum and maximum date bounds, default values, resolution levels, and operation modes.

    Index

    Constructors

    Properties

    maxDefaultValue?: Date
    maxValue: Date
    minDefaultValue?: Date
    minValue: Date
    mode: TimeMode
    resolution: TimeResolution

    Methods

    • Receives a date string or date object, validates it against the specified time options, and generates a formatted query string for usage as URL query parameter.

      Parameters

      • date: string | Date

        The date-like string or date object to be parsed and converted.

      Returns string

      A formatted query string, or an empty string if the date is invalid.

    • Generates a formatted query string from a provided date range for usage as URL query parameter. The provided dates are shortened to fit the defined resolution.

      Parameters

      • lowerLimit: string | Date

        The lower bound of the time range as a date-like string or date object.

      • upperLimit: string | Date

        The upper bound of the time range as a date-like string or date object.

      Returns string

      A formatted query string, or an empty string if the dates are invalid.

    • Helper method to quickly generate a formated query string from the default time restriction provided by the time options.

      Returns undefined | string

      The formatted defaults as query string or undefined if no defaults are available.

    • Simple date transform method from a date-like string to a date object without validating it against the time options.

      Parameters

      • dateStr: string

        The date string to be parsed.

      Returns undefined | Date

      The resulting Date object if the input is valid, otherwise undefined.

    • Formats a given date into a string, representing the week range from Monday to Sunday that the date falls into.

      Parameters

      • date: Date

      Returns string

    • Formats a date range as a string, separated by a forward slash and taking the resolution into account when defining the precision of the date strings.

      Parameters

      • lowerLimit: Date

        The starting date of the range.

      • upperLimit: Date

        The ending date of the range.

      • resolution: TimeResolution

        The resolution of the date range, can be 'day', 'week', 'month', or 'year'.

      Returns string

      A query string representing the date range formatted according to the specified resolution.

    • Constructs a query string based on a single date value and a specified time resolution.

      Parameters

      • date: Date

        The date value to be formatted.

      • resolution: TimeResolution

        The time resolution specifying the format (e.g. day, week, month, year).

      Returns string

      A formatted string representation of the date based on the provided resolution.